How about something like this?

################################

#Check the length
unless(length($myScalar) != 8){
   die("Bad Scalar!  Bad!\n");
}

#Get the parts
if($myScalar =~ /^([^0-9]*)(\d+.*)$/ ){
   print "$1 $2\n";
}

################################

NOTE:  NEVER name your variable $a.  $a and $b are special variables
used in sorting.


-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
Ng, Bill
Sent: Monday, May 01, 2006 12:55 PM
To: perl-win32-users@listserv.ActiveState.com
Subject: Easy One

Real simple,

        I have a string, "$a" for arguments sake, that contains a single
word.  The word will always have exactly 8 characters in it, most likely
something like "ABCD1234".  I need to split this up into two strings ($b
& $c), the first string needs to contain all the characters before the
first number in the word ("ABCD" in this example), the second string
needs everything after, and including, the first number in the word
"1234" in this example.

        Now, substr() would be a walk in the park, except for the fact
that I can't guarantee the first number will always be in the fifth
position ... it might come in any position between 3 and 7.  How would
YOU go about doing this?  Inquiring minds want to know.

Bill in Brooklyn

_______________________________________________
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


_______________________________________________
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to