Finding the carret position in a regular expression
kibleur.christophe at gmail.com
Thu Nov 23 10:36:56 CET 2006
supposed I've got the following text :
mytext = "for <myvar> in <somelist>:"
with the following simple pattern : pattern = "<[a-z]+>"
I use re.findall(pattern, mytext) wich returns :
Now, I want my prog to return the positions of the returned list
elements, ie :
<myvar> was found at position 5 in mytext
<somelist> was found at position 16 in mytext
How can I implement this ? Sorry if it's trivial, that's the first time
I use regular expressions.
More information about the Python-list