in reply to regex: something...(!something)...something
I think you've basically got it right.
/^somebegin(?!something)someend$/
Should work. The only complexity involves lookahead vs. backtrack and because you have stuff both before and after the stuff you don't want, that won't matter (in terms of the truth of the statement, I have no idea about the efficiency).
Personally, if I'm confused by something like this I opt for the slow but readable...
if ( /^somebegin(.*)someend$/ ) { my $middle = $1; if ( $middle !~ /^something$/ ) { # woot } }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: regex: something...(!something)...something
by aaaone (Initiate) on Jul 17, 2008 at 17:31 UTC | |
by olus (Curate) on Jul 17, 2008 at 17:57 UTC | |
by aaaone (Initiate) on Jul 17, 2008 at 18:02 UTC | |
by blazar (Canon) on Jul 18, 2008 at 22:18 UTC |