正则表达式只匹配货币中的数字 [英] Regex to match only numbers in currency
本文介绍了正则表达式只匹配货币中的数字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果可能的话,我试图让 VB 正则表达式只匹配货币序列中的数字,而不需要额外的替换行.它需要在开头寻找一个以 + 结尾的数字,并返回中间的内容,减去任何逗号.
I'm trying to get a VB regex to match only the numbers in a currency sequence without additional substitution lines if possible. It needs to look for a number with + on end $ at the start and return what's in the middle, minus any commas.
相应地
$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
我可以轻松地获得与值的匹配,但我无法弄清楚如何摆脱尾随的 + 或前缀和逗号.
I can easily get the match to the value but I can't figure out how to get rid, of the trailing + or the prefix and commas inside.
推荐答案
你的正则表达式是 \$(\d+(,?\d+)*)\+
.第 1 组正是您要找的
检查此处
Your regex is \$(\d+(,?\d+)*)\+
. Group 1 is what you are looking for
Check here
检索结果后,您应该从中删除逗号
After retrieving results you should remove commas from it
这篇关于正则表达式只匹配货币中的数字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文