Rob Dixon wrote:
>
> Justino Berrun wrote:
> > #hello, is there a way to split a string between a digit and character
> > #without losing the digit or the character
> > #Any help would be very appreciated
> >
> > $string='hello...4546perl.......2366Pogrammers..3435'; #e.g. would
> > make three new strings
> >
> > @newstrings=split(/(\d)([a-zA-Z])/,$string); #<--- no success
> > here
> > print join(":",@newstrings);
> >
> > #working toward an output like so:
> > #hello...4546:perl.......2366:Pogrammers..3435
>
> Hi.
>
> And another way. If you just need the colon-separated string and not
> the intermediate array you might as well go straight there.
>
> ($newstring = $string) =~ s/(\d)([a-zA-Z])/$1:$2/g;
If you use look-ahead and look-behind as in Janek's example then you
don't need to capture anything to $1 and $2:
( my $newstring = $string ) =~ s/(?<=\d)(?=[a-zA-Z])/:/g;
John
--
use Perl;
program
fulfillment
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]