Regular Expression: Matching substring
Leon
vanillayangyang at gmail.com
Wed Apr 12 23:24:07 EDT 2006
Hi Kevin,
You may notice that, for matching the regex (0|(1(01*0)*1))*, the left
most
three characters of a string must not be ``101" while not followed by
an `0'.
After reading the first `1', automata expects `1' or ``00" or ``010"
or ``11",
right?:)
Kevin CH 寫道:
> 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