Currently, I am working with Google Maps and encountering an issue with distance values being returned as strings like 1,230.6 km
. My goal is to extract the floating number 1230.6
from this string.
Below is my attempted solution:
var t = '1,234.04 km';
var a = t.replace(/[^0-9]/g, '') // 123404
parseFloat(t) // 1
Can anyone assist me in fixing this using Regex? Your guidance would be greatly appreciated.