in reply to conditional regex
for a simple question I would prefer a simple solution (maybe not so perfect but easy to understand also to non-regexperts). This does exactly "match y or yes in case-insensitive manner":
while(<>) { print "yes\n" if /(y|yes)/i; }
update: above will match everything with a 'y' inside as ikegami observed. Below code does what I meant (this time tested before posting)
foreach (qw( YES YE Y yes ye y ys es s e Yeeessseeseeesssssess)){ print "$_ = yes\n" if /^(y|yes)$/i; }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: conditional regex
by ikegami (Patriarch) on Aug 23, 2010 at 03:31 UTC | |
by BrimBorium (Friar) on Aug 23, 2010 at 20:07 UTC | |
by ikegami (Patriarch) on Aug 23, 2010 at 20:55 UTC |