You don't even need a regex although you could use one...

# untested
my $num = 92739874598745;
$num =~ /^(\d*)(d{4})(\d{5})$/;
my ($n1, $n2, $n3) = ($1, $2, $3);

Or you could do this...

# untested
my $num = 92739874598745;
my $n1 = substr($num, 0, length($num) - 9);
my $n2 = substr($num, -9, 4);
my $n3 = substr($num, -5);

Also add some error checking unless you are sure that the number is at least
9 chars long.

Rob


-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Thursday, November 29, 2001 3:32 PM
To: [EMAIL PROTECTED]
Subject: Regular expression help


I need help creating a regular expression to do the following.

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
_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users
_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users

Reply via email to