reusing parts of a string in RE matches?

mpeters42 at gmail.com mpeters42 at gmail.com
Wed May 10 21:59:57 CEST 2006


Exactly,

Now this will work as long as there are no wildcards in the pattern.
Thus, only with fixed strings.  But if you have a fixed string, there
is really no need to use regex, as it will complicate you life for no
real reason (as opposed to simple string methods).

With a more complex pattern (like 'a.a': match any character between
two 'a' characters) this will get the length, but not what character is
between the a's.

To actually do that you will need to iterate through the string and
apply the pattern match (which matches only the beginning of a string)
to a indexed subset of the original (see example in the last post)




More information about the Python-list mailing list