in reply to what is the best way to seperate the digits and strings from variable ?
Your question is a little vague, but if you want to extract digits at the beginning of a string you can use the following regex:
or, more concisely:my $variable = '12345(checkthis)'; $variable =~ /^(\d*)/; my $start_digits = $1;
Note that in the last example you HAVE to put parenthesys around $start_digits, to force a list/array context evaluation.my $variable = '12345(checkthis)'; my ($start_digits) = $variable =~ /^(\d*)/;
Flavio (perl -e 'print(scalar(reverse("\nti.xittelop\@oivalf")))')
Don't fool yourself.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: what is the best way to seperate the digits and strings from variable ?
by dbwiz (Curate) on May 09, 2005 at 10:58 UTC | |
by polettix (Vicar) on May 09, 2005 at 13:04 UTC | |
by Tanktalus (Canon) on May 09, 2005 at 14:39 UTC | |
by polettix (Vicar) on May 09, 2005 at 15:46 UTC | |
by rnahi (Curate) on May 09, 2005 at 19:37 UTC | |
| |
by Errto (Vicar) on May 10, 2005 at 02:49 UTC |