Re: Negate a regular expression

2006-12-30 Thread Dr.Ruud
"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

Re: Negate a regular expression

2006-12-30 Thread Leonid Grinberg
!~ 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

Re: Negate a regular expression

2006-12-30 Thread Mathew Snyder
Chad Perrin wrote: > 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 wa

Re: Negate a regular expression

2006-12-30 Thread Chad Perrin
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

Re: Negate a regular expression

2006-12-29 Thread Wiggins d'Anconia
Mathew Snyder wrote: 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|

Re: Negate a regular expression

2006-12-29 Thread Mathew Snyder
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)[

Re: Negate a regular expression

2006-12-29 Thread Mathew Snyder
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)[

Re: Negate a regular expression

2006-12-29 Thread Mathew Snyder
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)[

Re: Negate a regular expression

2006-12-29 Thread Ken Foskey
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

Negate a regular expression

2006-12-29 Thread Mathew Snyder
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? Mathew -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL