Re: Negate a regular expression




Leonid Grinberg wrote:
!~ will return true if the thing on the right does not match.
In your case, however, using unless seems more logical. Something like

exit unless (lc($answer) =~ /^[y|yes]$/)

This is great for Perl (yes, I realize this is a Perl newsgroup ;-),
but is there an actual way to negate a regular expression, say if we
were using sed? I know in sed you can use the 't' command after a 's'
to jump to a label if it matched, but that sometimes leads a bit of a
mess of spaghetti/line noise. I would find it odd that there would be
no ! (not) operator...

Just curious.

--
kruhft
metashell.blogspot.com

.