
hankcoder
New User
Sep 10, 2013, 12:10 AM
Post #1 of 6
(20751 views)
|
Regex split string into fixed length
|
Can't Post
|
|
The below regex works great but result appear as "1-111-111" instead I want it to appear as "111-111-1".
$line =~ s/(?<=\w)(?=(?:\w\w\w)+\b)/-/g; I don't know how to change the regex above, tried several attempt but still not working. Here is sample test code:
my (@list) = ( "12", "123", "1234", "12345", "123456", "1234567", "234", "2345", "23456" ); foreach $line (@list) { $line =~ s/(?<=\w)(?=(?:\w\w\w)+\b)/-/g; print "$line<br>"; }
|