Perl: the Markov chain saw | |
PerlMonks |
extracting number from stringby samuelalfred (Sexton) |
on Mar 05, 2009 at 09:31 UTC ( [id://748471]=perlquestion: print w/replies, xml ) | Need Help?? |
samuelalfred has asked for the wisdom of the Perl Monks concerning the following question:
Hello,
I have a string that looks for instance like this "Price 15.40". I want to extract the number out of that string resulting in 15.40. I have tried the following: $string=~s/\D//g which removes all "non-digit" characters from the string. However, then is also the decimal point "." removed which means that the result is 1540. So my question is how to make this expression remove all "non-digit" characters EXCEPT . and ,? Thanks!
Back to
Seekers of Perl Wisdom
|
|