Re: Negate a regular expression
- From: rvtol+news@xxxxxxxxxxxx (Dr.Ruud)
- Date: Sat, 30 Dec 2006 23:03:05 +0100
"Leonid Grinberg" schreef:
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''.
No. Your "[y|yes]" is equivalent to "[|esy]" and matches a single
character.
I guess you meant
/^(?:y|yes)$/
which can also be written as
/^y(?:es)?$/
or, if you don't mind the capturing, as
/^y(es)?$/
--
Affijn, Ruud
"Gewoon is een tijger."
.
- 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: Re: Negate a regular expression
- Index(es):
Relevant Pages
|