I want to be able to extract all numbers (including floating point) from a string in JavaScript.
"-5. -2 3.1415 test 2.4".match(...)
returns
["-2", "3.1415", "2.4"]
So far I have /[-+]?(\d*\.?\d+)/g
, but this seems to return 5
along with the other numbers. I want to avoid that since in the string the "word" is 5. and not 5 or 5.0. Any hints?