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

      I strongly suspected that the author was indeed the current holder of the multicoloured hat with bells on it; however, the lack of textual adornments and use of normal quotes, provided a small window of doubt: perhaps a potential usurper, or a runner-up in last year's Village Idiot Pageant.

      — Ken