Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Hi Monks,
I wanted your help to fix a couple of pattern matching regex that I have. My script:
Can you tell me why it prints case1 although my string does not have M inside?
I wanted your help to fix a couple of pattern matching regex that I have. My script:
#!/usr/bin/perl use strict; use warnings; my $s='IIIIIIIIIIIIIIIIIIIIIIIIIIOOOOOSSSSS'; if (0 == $s =~ tr/[IOSM]//c) { print "case1\n"; } elsif (0 == $s =~ tr/[IOS]//c) { print "case2\n"; }
Can you tell me why it prints case1 although my string does not have M inside?
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Pattern matching regex problem
by jwkrahn (Abbot) on Nov 23, 2021 at 08:53 UTC | |
by Anonymous Monk on Nov 23, 2021 at 09:05 UTC | |
by hippo (Bishop) on Nov 23, 2021 at 10:01 UTC | |
by bibliophile (Prior) on Nov 23, 2021 at 15:00 UTC | |
by ikegami (Patriarch) on Nov 23, 2021 at 21:00 UTC | |
by ikegami (Patriarch) on Nov 23, 2021 at 21:00 UTC | |
by eyepopslikeamosquito (Archbishop) on Nov 24, 2021 at 10:45 UTC | |
Re: Pattern matching regex problem
by Corion (Patriarch) on Nov 23, 2021 at 08:46 UTC |
Back to
Seekers of Perl Wisdom