> I have the following numbers:
 > 1006326869812
 > 563296853235993
 > 35968322963568389
 >
 > and it needs to be broken up like this
 >
 > 1006-3268-69812
 > 563296-8532-35993
 > 35968322-9635-68389
 >
 > Notice the second group of numbers is always 4 places and the
 > last group is always 5 places.
 >
 > I'm stumped and not to good with RE's. Any pointers would be great.
 >
 > Rob

Ron's answer was great. Here's a version with a function.

****************************************************************************
** Contents of t.pl
****************************************************************************
#!/usr/bin/perl
sub dashify($) { $_[0] =~ s/(\d*)(\d{4})(\d{5})/$1-$2-$3/ }
for(@ARGV){dashify(my $t=$_);printf("%40s -> \"%s\"\n",$_,$t)}
****************************************************************************
** Trial run
****************************************************************************
C:\>perl t.pl 1234567890123456 1234567890 123456789 123456 12345 1234
                         1234567890123456 -> "1234567-8901-23456"
                               1234567890 -> "1-2345-67890"
                                123456789 -> "-1234-56789"
                                   123456 -> "123456"
                                    12345 -> "12345"
                                     1234 -> "1234"
****************************************************************************
Hope this helps.

--- John

_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users

Reply via email to