Regular Expression: Matching substring

Kevin CH hierarchicalpolymorphist at gmail.com
Wed Apr 12 22:33:44 EDT 2006


Hi,

I'm currently running into a confusion on regex and hopefully you guys
can clear it up for me.

Suppose I have a regular expression (0|(1(01*0)*1))* and two test
strings: 110_1011101_ and _101101_1. (The underscores are not part of
the string.  They are added to show that both string has a substring
that matches the pattern.)  Applying a match() function on the first
string returns true while false for the second.  The difference is the
first one has unmatched chunk in the beginning while the second at the
end.  How's the regex rule work here?

Thanks.




More information about the Python-list mailing list