in reply to A Regex simple Question
if ($s =~ /^a(?!.*ab).*b$/) {
Cheers,
JohnGG
Update: If you want "a00000000ab" to match then you could change the look-ahead to ensure there is at least one character after the "ab".
use strict; use warnings; my @strings = qw{ a000000000b a0a0000b00b a0000ab000b a00000000ab }; print m{^a(?!.*ab.).*b$} ? qq{$_: matched\n} : qq{$_: unmatched\n} for @strings;
which produces
a000000000b: matched a0a0000b00b: matched a0000ab000b: unmatched a00000000ab: matched
|
|---|