If you do a split the split is based upon the pattern that you are entering,
@res=split(/(\D+)(\d+)/, $data);
The code you have here will split upon the match of none-numbers and then
numbers pattern, which is not
what he really wants he wants to really match a string, because there is no
dividing character to do a split
against. This is probalbly what you want.
; $String = "CDM123456"
; if ($String =~ /^(\D+)(.+)/)
{
; $Letters = $1
; $Other_Stuff = $2
}
; print "$String\n"
; print "Letters: $Letters Other Stuff: $Other_Stuff\n"
Steve K
> -----Original Message-----
> From: Shawn [SMTP:[EMAIL PROTECTED]]
> Sent: Thursday, March 01, 2001 3:55 AM
> To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
> Cc: [EMAIL PROTECTED];
> [EMAIL PROTECTED];
> [EMAIL PROTECTED];
> [EMAIL PROTECTED];
> [EMAIL PROTECTED]
> Subject: Re: REGULAR EXPRESSION IN SPLIT FUNCTION - PLEASE HELP ME.
>
> untested, but should work for you:
>
> @res=split(/(\D+)(\d+)/, $data);
>
> Shawn
>
>
> ----- Original Message -----
> From: <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Cc: <[EMAIL PROTECTED]>;
> <[EMAIL PROTECTED]>;
> <[EMAIL PROTECTED]>;
> <[EMAIL PROTECTED]>;
> <[EMAIL PROTECTED]>
> Sent: Thursday, March 01, 2001 2:13 AM
> Subject: REGULAR EXPRESSION IN SPLIT FUNCTION - PLEASE HELP ME.
>
>
> > DEAR FRIENDS,
> > PLEASE HELP ME REGARDING THE REGULAR EXPRESSION IN SPLIT FUNCTION
> >
> > data is : CDM210909 or FDM210909 ( ie start with 3characters followed
> > any no of numeric numbers)
> > probelm is : i need to split this word into CDM and 210909 ( split
> into
> > characters & numbers).
> >
> > --- ie, i wish to split this word into char (first 3 characters &
> remaining
> > )
> >
> > @res=split( / .{3}/ , $data );
> >
> > but i could'nt get the answer. can u please help me.
> > Expecting your ineffable Wishes,
> >
> > Pons.
> > Extn: 1328
> >
> --------------------------------------------------------------------------
> ----
> --
> >
> > Learn to Grow ------> Grow to Learn more & more.
> >
> --------------------------------------------------------------------------
> ----
> --
> >
> > _______________________________________________
> > ActivePerl mailing list
> > [EMAIL PROTECTED]
> > http://listserv.ActiveState.com/mailman/listinfo/activeperl
> >
> >
>
> _______________________________________________
> ActivePerl mailing list
> [EMAIL PROTECTED]
> http://listserv.ActiveState.com/mailman/listinfo/activeperl
_______________________________________________
Perl-Unix-Users mailing list. To unsubscribe go to
http://listserv.ActiveState.com/mailman/subscribe/perl-unix-users