how to extract decimal number from string using javascript

前端 未结 6 1921
春和景丽
春和景丽 2021-01-12 11:02

I want to extract decimal number 265.12 or 0.0 from alphanumeric string (say amount) having value $265.12+ or $265.12- or

6条回答
  •  一生所求
    2021-01-12 11:13

    Without error checks, following will do:

    var string = "$123123.0980soigfusofui"
    var number = parseFloat(string.match(/[\d\.]+/))
    

    123123.098

提交回复
热议问题