Re: Negate a regular expression



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.



Ok, nevermind. I just switched the order in which the check is made. I was
checking for anything other than the 'y' or 'yes' input and exiting if so. I
was then using the else clause as the actual execution if 'y' or 'yes' were
found. I put that first and the exit statement in the else clause and it does
what I was looking for.

Thanks for the correction of my regex though. That did help :D

Mathew
.



Relevant Pages

  • Re: SELECT FROM function in Access 2000
    ... >From clause - essentially as another table. ... The left and right square brackets are required, ... Roger dot Carlson at Spectrum-Health dot Org ... > resultset, then that resultset must be query-able again with a select. ...
    (microsoft.public.access.queries)
  • Re: Negate a regular expression
    ... Ken Foskey wrote: ... square brackets are a character class. ... probably a good idea to ignore whitespace around the error as well. ...
    (perl.beginners)
  • Re: help using a parameter in an In (...) criteria
    ... I don't understand why my three other parameters are in square brackets in ... don't understand why in the SELECT clause the table/field are as ... Here is my SQL: ... FROM Survey INNER JOIN GroupLocation ON Survey.Survey_ID = ...
    (microsoft.public.access.queries)
  • Re: Negate a regular expression
    ... square brackets are a character class. ... combination of 'y' or 'yes' will cause the script to exit. ... So having the regex look also for whitespace characters will ...
    (perl.beginners)
  • Re: Negate a regular expression
    ... square brackets are a character class. ... combination of 'y' or 'yes' will cause the script to exit. ... So having the regex look also for whitespace characters will ...
    (perl.beginners)