【问题标题】:Regex to match only numbers in currency正则表达式仅匹配货币中的数字
【发布时间】:2016-10-16 14:43:45
【问题描述】:

如果可能,我正在尝试让 VB 正则表达式仅匹配货币序列中的数字,而无需额外的替换行。它需要查找开头带有 + 且结尾为 $ 的数字,并返回中间的数字,减去任何逗号。

因此

 $10,000+ match returns 10000

$20,000+ match returns 20000

$30,000+ match returns 30000

$1,000,000+ match returns 1000000

$10,000 (anything without the trailing +) should *not* match

我可以轻松地获得与值的匹配,但我不知道如何摆脱尾随的 + 或内部的前缀和逗号。

【问题讨论】:

    标签: regex vb.net


    【解决方案1】:

    您的正则表达式是\$(\d+(,?\d+)*)\+。第 1 组是您要查找的内容
    检查here

    检索结果后,您应该从中删除逗号

    【讨论】:

      猜你喜欢
      • 2017-09-20
      • 2014-10-18
      • 2020-09-12
      • 2012-11-30
      • 1970-01-01
      • 1970-01-01
      • 2021-10-01
      • 2022-11-26
      相关资源
      最近更新 更多