Reputation: 111
I have a string ="this is test 12.00 and 15.00". My requirement is to remove the decimals from the string .
My output should be "this is test 12 and 15". I have tried splitting the string and remove the decimals and replacing it however not working right. can some expert advise on this please.
Upvotes: 1
Views: 31
Reputation: 5648
You could use the next regexp /\.\d{0,}/g
And with the replace
function, you delete the decimal numbers.
Hope this helps :>
let str ="this is test 12.00 and 15.00"
console.log(str.replace(/\.\d{0,}/g,''))
Upvotes: 2