Re: Negate a regular expression
- From: lgrinberg@xxxxxxxxx (Leonid Grinberg)
- Date: Sat, 30 Dec 2006 15:53:31 -0500
!~ 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]$/)
should work. The ^ and $ are there to make sure that the string
contains nothing but ``y'' or ``yes''. Make sure that you do
chomp($answer) before running this, though, because the newline
character may break it.
.
- Follow-Ups:
- Re: Negate a regular expression
- From: kruhft
- Re: Negate a regular expression
- From: Dr.Ruud
- Re: Negate a regular expression
- References:
- Negate a regular expression
- From: Mathew Snyder
- Re: Negate a regular expression
- From: Chad Perrin
- Re: Negate a regular expression
- From: Mathew Snyder
- Negate a regular expression
- Prev by Date: $myfile.doc page count
- Next by Date: Re: Strings vs Arrays
- Previous by thread: Re: Negate a regular expression
- Next by thread: Re: Negate a regular expression
- Index(es):