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.In reply to Re^3: what is the best way to seperate the digits and strings from variable ?
by polettix
in thread what is the best way to seperate the digits and strings from variable ?
by swaroop
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |