in reply to Keeping lookahead assertion from looking to the end of the string?

If you just want to check if the string matches, Limbic~Regions example will probably do it.

Although you didn't say it, I suppose you want to catch the substrings between 'start' and 'end' - otherwise you don't have to care about overlapping. In that case you could do something like the following:

#!usr/bin/perl use warnings; $_ = "start b2 end start b2 b2 end start b2 end"; @Matches = / # list context to catch all (?<= \b start \b )# 'start' must precede ( .*? ) # catch fewest possible anythings (?= \b end \b )# 'end' must follow /gx # global and expressive and print join("\n", @Matches); __DATA__ b2 b2 b2 b2

update: normal matching without look-ahead and look-behind will have the same effect with the example string:

@Matches = / \b start \b ( .*? ) \b end \b /gx

update: I overlooked that Limbic~Regions regex catches the substring too. Shame on me!

~Django
"Why don't we ever challenge the spherical earth theory?"

Replies are listed 'Best First'.
Re: Re: Keeping lookahead assertion from looking to the end of the string?
by Anonymous Monk on Sep 05, 2002 at 12:04 UTC
    Um, my RegEx does catch the substring between "start" and "end" as depicted in the print statment. As always, TIMTOWTDI.