Re: YA Regex problem: lookahead assertion

2005-03-24 Thread John W. Krahn
Jan Eden wrote: John W. Krahn wrote on 23.03.2005: This should work (untested) while ($content =~ m#(.+?)(.+?)(?=|\z)#gs) { and thanks. I tried Offer Kaye's first guess, too, and I think I can explain why it does not work. If you make the lookahead optional, the regex will try to match as few chara

Re: YA Regex problem: lookahead assertion

2005-03-24 Thread Jan Eden
Offer Kaye wrote on 23.03.2005: >Change your RE to: m#(.+?)(.+?)(?=|$)#gs > >In other words, look ahead to either a or the end of the string >("$"). I have to admit this problem wasn't as simple as I initially >thought - I still have no idea why my first guess didn't work: >m#(.+?)(.+?)(?=)?#gs >

Re: YA Regex problem: lookahead assertion

2005-03-23 Thread John W. Krahn
Jan Eden wrote: Hi, Hello, I use the following regex to split a (really simple) file into sections headed by .+?: while ($content =~ m#(.+?)(.+?)(?=)#gs) { ... } This works perfectly, but obviously does not catch the last section, as it is not followed by . How can I catch the last section wi

RE: YA Regex problem: lookahead assertion

2005-03-23 Thread Charles K. Clarkson
Jan Eden wrote: : Hi, : : I use the following regex to split a (really simple) file into : sections headed by .+?: : : while ($content =~ m#(.+?)(.+?)(?=)#gs) { : ... : } The answer may be in your description. Use 'split'. When you use a capture inside the reg

Re: YA Regex problem: lookahead assertion

2005-03-23 Thread Offer Kaye
On Wed, 23 Mar 2005 17:06:59 +0100, Jan Eden wrote: > Hi, > > I use the following regex to split a (really simple) file into sections > headed by .+?: > > while ($content =~ m#(.+?)(.+?)(?=)#gs) { > ... > } > > This works perfectly, but obviously does not catch the last section, as it is >

YA Regex problem: lookahead assertion

2005-03-23 Thread Jan Eden
Hi, I use the following regex to split a (really simple) file into sections headed by .+?: while ($content =~ m#(.+?)(.+?)(?=)#gs) { ... } This works perfectly, but obviously does not catch the last section, as it is not followed by . How can I catch the last section without * doing a se