in reply to How do I split a string which has letters then numbers?

my ($word, $number) = split /(?<=\D)(?=\d)/; my ($word, $number) = /^(\D+)(\d+)$/;
Change the regexes if your data needs more complex parsing.

hth

2;0 juerd@ouranos:~$ perl -e'undef christmas' Segmentation fault 2;139 juerd@ouranos:~$

Replies are listed 'Best First'.
Re: Re: How do I split a string which has letters then numbers?
by japhy (Canon) on Jan 17, 2002 at 04:43 UTC
    If you're using split(), I'd be inclined to do split /(?=\d)/, $_, 2;. It feels faster to me.

    _____________________________________________________
    Jeff[japhy]Pinyan: Perl, regex, and perl hacker.
    s++=END;++y(;-P)}y js++=;shajsj<++y(p-q)}?print:??;