To all,
I have a string of thirty digits that I need to insert dashes after every 5 digits, and then a <br> after the 15th digit, as in:
This is what I've come up with. What are some other alternatives to this regex?012345678901234567890123456789 ==> 01234-56789-01234<br>56789-01234-56789
Where do you want *them* to go today?#!/perl/bin/perl -w use strict; my $s = "012345678901234567890123456789"; print $s, "\n"; $s =~ s/(\d{5})(\d{5})(\d{5})(\d{5})(\d{5})(\d{5})/$1-$2-$3<br>$4-$5-$ +6/; print $s, "\n";
In reply to A regex question... by thezip
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |