in reply to Re^2: what is the best way to seperate the digits and strings from variable ?
in thread what is the best way to seperate the digits and strings from variable ?
Here, I'm considering digits as a character class, not as components of a number whose semantic is different from that of a string; this is why I name my variable $start_digits, not $num as you do. As you've surely noted, the OP never talks about numbers, always about digits (anyway, as I noted in my post, the OP was not clear about the usage of this extracted data).
Thus, when I thought about putting "*" or "+"*, I considered that if there were no digits it was good, and the returned string would be empty.
I think you can agree with me that, had the OP asked for initial letters, the regex:
would do the job.my $variable = "abc123"; my ($letters) = $variable =~ /^([a-zA-Z]*)/;
*I swear I thought about that!
Flavio (perl -e 'print(scalar(reverse("\nti.xittelop\@oivalf")))')
Don't fool yourself.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^4: what is the best way to seperate the digits and strings from variable ?
by Tanktalus (Canon) on May 09, 2005 at 14:39 UTC | |
by polettix (Vicar) on May 09, 2005 at 15:46 UTC | |
Re^4: what is the best way to seperate the digits and strings from variable ?
by rnahi (Curate) on May 09, 2005 at 19:37 UTC | |
|