in reply to Regex to match 20 chars of some digits followed by some spaces

Hi leriksen, You were so close to getting it right, if you extend the regexp just a little bit with the match-time interpolation technique.
use strict; use warnings; while (<DATA>) { chomp; print m/(\d{1,20})(??{' ' x (20 - length($1))})/ ? "match\n" : "not match\n"; } __DATA__ " 123451234512345" " 123451234512345 " "123451234512345 " "1234512345 " "123 451 2345 " " "
And the output is exactly as expected -
not match not match match match not match not match