in reply to Regex to match 20 chars of some digits followed by some spaces
Here's my attempt which seems a little simpler than some of the others.
m[^ \d (?: (?<! \x20 ) \d | \x20 ){19} $]x
Which says that the entire string must constist of a digit followed by 19 ((digits not preceeded by spaces) or spaces).
print m[^ \d (?: (?<!\x20) \d | \x20 ){19} $]x ? 'Yes:' . $_ : ' No:' . $_ for @t; No: 123451234512345 No: 123451234512345 Yes:123451234512345 Yes:1234512345 No:123 451 2345 No:
|
|---|