Excellent. Piqued my interest in this approach, which led to a few observations:
- you probably want to anchor your match
- you could have used dot-star instead of .{0,18}, or you could have specified the chars for the dot (TIMTOWTDI) -- probably the most efficient thing would be to specify (?!\d* +\d), which made me realize...
- it can be done with a positive lookahead like so: /^\d(?=\d* *$)[\d ]{19}$/ ("leading digit, followed by digits, then spaces, then end of string, etc.")
The PerlMonk tr/// Advocate