使用逗号提取超过1000的数字的模式是什么。我尝试了很多不同的模式,但我使用的模式只提取逗号之前的第一个数字而不是逗号的整数。那么我可以使用什么模式来提取包含逗号的999以上的任何数字。
这是我的模式:"(\ d *,)\ d *"
1000以下数字的工作模式:
Dim rgxPostsCount As New Regex("class=[""]counts_media[""]>\d*")
Dim mchPostsCount As Match = rgxPostsCount.Match(strData)
If mchPostsCount.Success Then
Dim strPostsCount As String = mchPostsCount.Value.Substring(21, mchPostsCount.Length - 21)
MessageBox.Show(strPostsCount)
超过999的数字的非工作模式:我想保留逗号。 如果strPostsCount> 999然后 rgxPostsCount =新正则表达式(" class = [""] counts_media [""]>(\ d *,)\ d *") chPostsCount = rgxPostsCount.Match(strData) MessageBox.Show(mchPostsCount.Value) 结束如果
答案 0 :(得分:0)
作为ERE,
[0-9]{1,3}(,[0-9]{3})+
一些例子:
$ for n in \ 444444,000,000 1,000,000 11,000,000 11,000,00 11,000,000 \ 11,000,000 1,000 999 9,99 10,000; do \ echo $n '->' $(echo $n | grep -E -o -w '[0-9]{1,3}(,[0-9]{3})+$' || echo nope); \ done 444444,000,000 -> nope 1,000,000 -> 1,000,000 11,000,000 -> 11,000,000 11,000,00 -> nope 11,000,000 -> 11,000,000 11,000,000 -> 11,000,000 1,000 -> 1,000 999 -> nope 9,99 -> nope 10,000 -> 10,000
答案 1 :(得分:0)
此正则表达式匹配每个数字> = 1000:
0*[1-9][\d]{3,}(?:[,.]\d+)?
如果您只想用逗号匹配数字:
0*[1-9][\d]{3,},\d+