in reply to Zero-width look-ahead regexp question

/^FOO((?!BA[RZ]$).*)/ will do what you want. Reading out loud:
m{ ^ # start of the string FOO ( # this will become $1 (?! # must not be BA[RZ]$ # BAR or BAZ followed by end-of-string ) .* # now anything else (except "\n") # no need to "$", because ".*" will happily swallow it all ) }x
Checking it out:
$ perl -MData::Dumper -le '%h = map { $_ => /^FOO((?!BA[RZ]$).*)/ ? $1 + : q(does NOT match) } qw/FOO FOOZIM FOOBAR FOOA FOOBAZ FOOBARX/; $Da +ta::Dumper::Terse = $Data::Dumper::Indent = 1; print Dumper \%h' { 'FOOBAR' => 'does NOT match', 'FOOZIM' => 'ZIM', 'FOOA' => 'A', 'FOOBARX' => 'BARX', 'FOOBAZ' => 'does NOT match', 'FOO' => '' }

Replies are listed 'Best First'.
Re^2: Zero-width look-ahead regexp question
by rovf (Priest) on Jul 01, 2008 at 12:19 UTC
    Thanks a lot, too!!!!
    -- 
    Ronald Fischer <ynnor@mm.st>