Re: Regular Expression: Matching substring

2006-04-13 Thread Fredrik Lundh
"Kevin CH" wrote: news:[EMAIL PROTECTED] > Thank you for your reply. > > > Perhaps you are using grep, or you have stumbled on the old deprecated > > "regex" module and are using that instead of the "re" module. Perhaps > > not as you are using only 2 plain vanilla RE operations which should > > w

Re: Regular Expression: Matching substring

2006-04-12 Thread Kevin CH
Thank you for your reply. > Perhaps you are using grep, or you have stumbled on the old deprecated > "regex" module and are using that instead of the "re" module. Perhaps > not as you are using only 2 plain vanilla RE operations which should > work the same way everywhere. Perhaps you are having t

Re: Regular Expression: Matching substring

2006-04-12 Thread John Machin
On 13/04/2006 12:33 PM, Kevin CH wrote: > 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 st

Re: Regular Expression: Matching substring

2006-04-12 Thread Kevin CH
Oh yea, I see what's my confusion now. In the first string, I didn't consider 11 and 0 matches the pattern without the repetition. Actually what I did is I entered the pattern and the test strings into kudos (a python regexp debugger) and got the match groups, which didn't have 11 and 0 as matche

Re: Regular Expression: Matching substring

2006-04-12 Thread Leon
You are right. In fact the procedure is as follows: The substr ``101101" is no problem, if stop here, match will successful. But the tailing `1' occurs, so we may imagine the working automata move to a state, which according to the regexp's outer most `)', and ready to repeat the whole regexp again

Re: Regular Expression: Matching substring

2006-04-12 Thread Kevin CH
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 e

Re: Regular Expression: Matching substring

2006-04-12 Thread Leon
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 run

Regular Expression: Matching substring

2006-04-12 Thread 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 sub