Re: Negate a regular expression
- From: perrin@xxxxxxxxxxxx (Chad Perrin)
- Date: Sat, 30 Dec 2006 01:20:17 -0700
On Fri, Dec 29, 2006 at 11:36:25PM -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;
Will that do what I want?
If you want anything but a given pattern, the best way to do it is
usually by using the !~ operator. Thus, if you have a pattern $foo,
this matches that pattern:
exit if $ans =~ m/$foo/i;
.. . . while this matches anything but that pattern:
exit if $ans !~ m/$foo/i;
--
CCD CopyWrite Chad Perrin [ http://ccd.apotheon.org ]
"A script is what you give the actors. A program
is what you give the audience." - Larry Wall
.
- Follow-Ups:
- Re: Negate a regular expression
- From: Mathew Snyder
- Re: Negate a regular expression
- References:
- Negate a regular expression
- From: Mathew Snyder
- Negate a regular expression
- Prev by Date: Re: Negate a regular expression
- Next by Date: [bug or restriction about msgget] I have a confusion about msgget(System V message queue)
- Previous by thread: Re: Negate a regular expression
- Next by thread: Re: Negate a regular expression
- Index(es):
Relevant Pages
|
|