in reply to Re: Need a regular expression to check the first digit
in thread Need a regular expression to check the first digit

This node falls below the community's threshold of quality. You may see it by logging in.
  • Comment on Re^2: Need a regular expression to check the first digit

Replies are listed 'Best First'.
Re^3: Need a regular expression to check the first digit
by kcott (Archbishop) on May 22, 2021 at 10:02 UTC

    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

        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