http://www.perlmonks.org?node_id=1018262


in reply to Re: how to split the string into two or three numbers based on certain value.
in thread how to split the string into two or three numbers based on certain value.

A slight simplification. I'm not sure the  \G is necessary: the given test string produces the same groups with/without it. (Update: And the same caveat about a regex solution possibly not being optimum.) See Extended Patterns in perlre.

>perl -wMstrict -le "my $s = '79899920179'; ;; my @n = $s =~ m{ \G (\d{2,3}?) (?(?{ $^N < 32 }) (*FAIL)) }xmsg; printf qq{'$_' } for @n; " '79' '89' '99' '201' '79'