swissknife has asked for the wisdom of the Perl Monks concerning the following question:
Dear Monks
I have a 6 character string (alphanumeric) and i want to check the particular char at particular position to buld my condition. for example: in string XXXXpX, i care only about char "p" at 5th position and if it matches then my condition is met.
i used following regex in my program:
my $strTest = "ABCDpF"; if (grep {m/.?.?.?.?p.?/i} $strTest) { print "String matched the Pattern"; }
it works in most of my test cases. but i used a string "tp7avs" where i assume it should not match but it does. Could anyone help?
-KAKA-
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Perl RegEx doubt
by choroba (Cardinal) on Jun 07, 2016 at 12:47 UTC | |
|
Re: Perl RegEx doubt
by Eily (Monsignor) on Jun 07, 2016 at 12:35 UTC | |
|
Re: Perl RegEx doubt
by Corion (Patriarch) on Jun 07, 2016 at 12:35 UTC | |
|
Re: Perl RegEx doubt
by hippo (Archbishop) on Jun 07, 2016 at 12:35 UTC | |
|
Re: Perl RegEx doubt
by toolic (Bishop) on Jun 07, 2016 at 12:36 UTC | |
|
Re: Perl RegEx doubt
by stevieb (Canon) on Jun 07, 2016 at 12:45 UTC | |
by AnomalousMonk (Archbishop) on Jun 07, 2016 at 14:50 UTC |