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'
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: how to split the string into two or three numbers based on certain value.
by venky4289 (Novice) on Feb 12, 2013 at 08:19 UTC | |
by AnomalousMonk (Archbishop) on Feb 12, 2013 at 15:41 UTC |
In Section
Seekers of Perl Wisdom