in reply to Re: conditional regex
in thread conditional regex
Probably not what you want.
There's a much simpler solution. Reverse the subject and the pattern:
Or, instead of the pattern match:for my $str (qw[YES YE Y yes ye y YS ES S ys es s YEESS YYYEEs]) { say "$str: ", "yes" =~ /^\Q$str/i ? "ok" : "not ok"; } __END__ YES: ok YE: ok Y: ok yes: ok ye: ok y: ok YS: not ok ES: not ok S: not ok ys: not ok es: not ok s: not ok YEESS: not ok YYYEEs: not ok
say "ok" unless index "yes", lc $str;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: conditional regex
by BrowserUk (Patriarch) on Aug 22, 2010 at 15:18 UTC |