s/(\D+)$//; my $units = $1;
Then proceed with the more standard problem of recognizing a number. See:
Normalizing your input in this way can be a powerful trick that allows you to more clearly identify and deal with your edge cases. Unless performance is absolutely stupendously crucial there is no reason to implement a monolithic regexp that handles every possibility.
Matt
In reply to Re: Identifying and parsing numbers
by mojotoad
in thread Identifying and parsing numbers
by dragonchild
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |