Leon wrote: > 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?:) Why it must expect "010"? Why not say "0110", since 1* can represent 0 or more repetitions.
> > > 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. -- http://mail.python.org/mailman/listinfo/python-list