首页 > 解决方案 > 从字符串中提取逗号分隔的数字

问题描述

我想使用 REGEX 从下面的字符串中提取逗号分隔的数字

String = "the Total Cost, being £10,000,000 at the date of this Agreement";

预期产出:10,000,000 英镑

我试过这个:

\£[^]\w,\d*,\d*

但它在 asp.net 代码中给了我一个错误:“Unterminated [] set”。

标签: regex

解决方案


使用这个正则表达式:

var str = "the Total Cost, being £10,000,000 at the date of this Agreement";
var regex = /£[\,\d]+/g;
var match = str.match(regex);
console.log(match);


推荐阅读