- or download this
perl -e 'my $re = qr!yes|no!; print "$re\n";'
prints: (?-xism:yes|no)
- or download this
my $re = qr!yes|no!;
print "yes or no!\n" if "yes" =~ $re;
print "yes or no only" if "maybe" !~ $re;
print "polite yes or no\n" if "yes thankyou" =~ /$re thankyou/;
- or download this
my $re = qr!yes|no!;
my $re2 = qr!\sthankyou!;
print "yes or no!\n" if "yes" =~ $re;
print "yes or no only" if "maybe" !~ $re;
print "polite yes or no\n" if "yes thankyou" =~ /$re$re2/;