Re: Negate a regular expression
- From: theillien@xxxxxxxxx (Mathew Snyder)
- Date: Fri, 29 Dec 2006 23:56:23 -0500
Ken Foskey wrote:
On Fri, 2006-12-29 at 23:36 -0500, Mathew Snyder wrote:
I'm trying to set up an if clause to exit if an answer given is anything but
either any case combination of 'y' or 'yes'. This is what I have:
exit if $ans =~ m/[^y|^yes]/i;
exit if $ans =~ m/^(y|yes)[ \t\r\n]*$/i;
The brackets are a group, square brackets are a character class. It is
probably a good idea to ignore whitespace around the error as well.
But that doesn't negate does it? Doesn't that look for the match at the
beginning of the text? Also, wouldn't it make more sense to just use '\s'
instead of each individual special character for whitespace?
.
- References:
- Negate a regular expression
- From: Mathew Snyder
- Re: Negate a regular expression
- From: Ken Foskey
- Negate a regular expression
- Prev by Date: Re: Negate a regular expression
- Next by Date: Re: Negate a regular expression
- Previous by thread: Re: Negate a regular expression
- Next by thread: Re: Negate a regular expression
- Index(es):
Relevant Pages
|