I'm looking for some REGEX or some other way in JS how to remove decimal numbers from string.
example input:
Mazda 6 2.0 Skyactiv-G Wagon 2018 - Startstop.sk - TEST
Mercedes C63 AMG Sound REVVING 6,3l V8
example output:
Mazda 6 Skyactiv-G Wagon 2018 - Startstop.sk - TEST
Mercedes C63 AMG Sound REVVING l V8
Everywhere I look people want to keep both integers and decimals and just remove strings. But I want to keep all integers just remove decimals (with comma,
or dot.
)
I tried something like:
var string = "Mazda 6 2.0 Skyactiv-G Wagon 2018 - Startstop.sk - TEST"
parseFloat(string.match(/[\d\.]+/))
// Result is 6
But this actually just again remove everything exept integers.