Re: Negate a regular expression
- From: "kruhft" <kruhft@xxxxxxxxx>
- Date: 30 Dec 2006 17:46:35 -0800
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
.
- References:
- Negate a regular expression
- From: Mathew Snyder
- Re: Negate a regular expression
- From: Chad Perrin
- Re: Negate a regular expression
- From: Mathew Snyder
- Re: Negate a regular expression
- From: Leonid Grinberg
- Negate a regular expression
- Prev by Date: Re: Strings vs Arrays
- Next by Date: Re: Strings vs Arrays
- Previous by thread: Re: Negate a regular expression
- Next by thread: Strings vs Arrays
- Index(es):