【问题标题】:Replace dot in a number [duplicate]替换数字中的点[重复]
【发布时间】:2019-11-12 12:10:12
【问题描述】:

我想用正则表达式替换Javascript中数字中的点;例如,如果 country_temp 为 1.234,我如何将值 1234 放入 country_temp2? 我尝试了以下方法:

const country_temp2 = country_temp.replace(/[a-zA-Z]*\**\s*\./g, "")
but it's not working.

编辑:原始字符串由字符、星号、数字和点组成 对不起,我写得很快。

【问题讨论】:

  • var country_temp2 = country_temp.replace(".","");?

标签: javascript regex


【解决方案1】:

试试这个:

country_temp.replace(/\./g,'')

【讨论】:

    猜你喜欢
    • 2013-06-23
    • 1970-01-01
    • 2023-02-17
    • 1970-01-01
    • 2019-01-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多