in reply to what is the best way to seperate the digits and strings from variable ?
$variable = '12345(checkthis)'; $variable += 0;
That numifies $variable, which happens to exclude everything starting from the first non-digit character.
Other (twisted) ways of doing the same would include the spacestation:
$variable = -+- '12345(checkthis)';
If, OTOH, you really want all the digits, regardless of them being in the beginning of the string, or even of them being together or separated by other chars, you can always use some silly regexen twisting such as:
$variable = join '', "12345(checkthis)" =~ /\d*/g;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: what is the best way to seperate the digits and strings from variable ?
by Roy Johnson (Monsignor) on May 09, 2005 at 15:53 UTC | |
by cog (Parson) on May 09, 2005 at 16:04 UTC |