Re: Positive lookahead assertion

2006-09-08 Thread Steve Holden
tobiah wrote: >>>Posted via a free Usenet account from http://www.teranews.com >> >>Its all about context. If you want to match something but only if it >>precedes something else, then you follow the regular expression for >>'something' by the regular expression for 'something else' where >>`someth

Re: Positive lookahead assertion

2006-09-07 Thread Paddy
Paddy wrote: > tobiah wrote: > > >> Posted via a free Usenet account from http://www.teranews.com > > > Its all about context. If you want to match something but only if it > > > precedes something else, then you follow the regular expression for > > > 'something' by the regular expression for 'som

Re: Positive lookahead assertion

2006-09-07 Thread Carl Banks
tobiah wrote: > Sorry, I should have tried harder. I see that the text > of the match is simply not consumed, so that: > > m = re.search('(?=foo)fo', 'food') > > succeeds, while > > m = re.search('(?=fox)fo', 'food') > > does not. They are more commonly used, and generally more useful

Re: Positive lookahead assertion

2006-09-07 Thread Paddy
tobiah wrote: > >> Posted via a free Usenet account from http://www.teranews.com > > Its all about context. If you want to match something but only if it > > precedes something else, then you follow the regular expression for > > 'something' by the regular expression for 'something else' where > >

Re: Positive lookahead assertion

2006-09-07 Thread tobiah
>> Posted via a free Usenet account from http://www.teranews.com > Its all about context. If you want to match something but only if it > precedes something else, then you follow the regular expression for > 'something' by the regular expression for 'something else' where > `something else` is enc

Re: Positive lookahead assertion

2006-09-07 Thread Neil Cerutti
On 2006-09-07, Paddy <[EMAIL PROTECTED]> wrote: > tobiah wrote: >> (?=...) >> Positive lookahead assertion. This succeeds if the contained >> regular expression, represented here by ..., successfully >> matches at the current location, and fails otherwise. But, >> once the contained expression has

Re: Positive lookahead assertion

2006-09-07 Thread Paddy
tobiah wrote: > (?=...) > Positive lookahead assertion. This succeeds if the contained > regular expression, represented here by ..., successfully > matches at the current location, and fails otherwise. > But, once the contained expression has been tried, the > matching engine doesn't advance at a

Re: Positive lookahead assertion

2006-09-07 Thread tobiah
Sorry, I should have tried harder. I see that the text of the match is simply not consumed, so that: m = re.search('(?=foo)fo', 'food') succeeds, while m = re.search('(?=fox)fo', 'food') does not. tobiah wrote: > (?=...) > Positive lookahead assertion. This succeeds if the c