in reply to Re: printing 20 characters in a line.
in thread printing 20 characters in a line.
To my eye the regex reads better if you start the memory group with a set of digits (thus removing the worry about leading spaces) and then follow with grouped spaces and digits with a quantifier of 0 to 19. That avoids the adjacent \s* tokens which might be a little confusing at first glance. Also, you don't need the parentheses around the match.
print qq{$1\n} while $str =~ m{(\d+(?:\s+\d+){0,19})}g;
I hope this is of interest.
Cheers,
JohnGG
|
|---|