Consider the following string:
var string="0px 0px 4.5px";
Now let's say I want to extract the numbers from that string. I will use the following regex:
var numbers=string.match(/\d+/g);
But what I get is:
["0","0","4"]
So you see that 4.5 was turned into an integer.So my question is how can I change the above regex to get floating numbers from a string
"0px 0px 4.5px".split(" ").map(parseFloat)["0px", "0px","4.5px"]. Shouldn't it split onpx? P.S: Checked it. It's works.split()returns, yes. But the call tomap()then parses those values into floats. Try it in console.