in reply to Re: Negative Index with "substr" Not Working
in thread Negative Index with "substr" Not Working
Try regex
sub test { my $str =shift; if(length($str)==11) { $str=~ m/^(\d(\d{6})\d+)$/; print"$1 $2\n"; } else { $str=~ m/^((\d{6})\d+)$/; print"$1$2 $2\n"; } } my $a='01234567890'; my $b ='15556667777'; test($a); test($b);
Output
01234567890 123456
15556667777 555666
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Negative Index with "substr" Not Working
by stevieb (Canon) on Nov 23, 2015 at 23:31 UTC |