regex - 从字符串中提取逗号分隔的数字
问题描述
我想使用 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”。
解决方案
使用这个正则表达式:
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);
推荐阅读
- maxima - 如何在最大值中将约束应用于链式法则
- oauth-2.0 - 如何使用 python 验证 Microsoft AD 授予的 OAuth 2.0 令牌?
- regex - 如何匹配但排除递归模式中的分隔符
- postgresql - PostgreSQL、只读用户和 PgAdmin
- flutter - Flutter:TextFormField onchange 值到 Text 小部件
- c# - 即使第一个没有成功,Asp.Net Core 策略也会运行所有要求
- c# - 错误 CS7036:没有给出与所需形式参数相对应的参数
- git - 在两个 git 存储库之间不断合并?
- python - Truncate stdout of subprocess.run() without shell=True
- php - 从 sh 文件运行单个 apache2 请求