RegEx: find all occurances of a single character in a string
Franz Steinhaeusler
franz.steinhaeusler at utanet.at
Tue Dec 14 08:05:38 EST 2004
given a string:
st="abcdatraataza"
^ ^ ^ ^ (these should be found)
I want to get the positions of all single 'a' characters.
(Without another 'a' neighbour)
So I tried:
r=re.compile('[^a]a([^a]')
but this applies only for
the a's, which has neighbours.
So I need also '^a' and 'a$'.
Am I doing something wrong?
Is there a easier solution?
How can I quickly get all these positions?
Thank you in advance.
--
Franz Steinhaeusler
More information about the Python-list
mailing list