in reply to Re^2: Need a regular expression to check the first digit
in thread Need a regular expression to check the first digit
You said "Exactly." and then went on to describe something completely different!
A regex is not required, nor is substr. The condition can be written as simply as:
length == 9 and ! index $_, 5
Here's an example:
$ perl -E ' my @strings = qw{1 234 5 678 567890123 qwerty}; say for grep +(length == 9 and ! index $_, 5), @strings; ' 567890123
The 9 and 5 could be replaced with variables for greater flexibility; however, that wasn't what the OP asked for.
— Ken
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^4: Need a regular expression to check the first digit
by Anonymous Monk on May 22, 2021 at 17:48 UTC | |
by kcott (Archbishop) on May 23, 2021 at 01:09 UTC |