正则表达式查询

时间:2012-08-24 10:08:08

标签: regex c#-4.0

string x =“搜索结果:1 - 20的1,312,224为您的搜索条件”。

需要验证它包含“搜索结果:(X)中的1 - 20为您的搜索条件”和(x)可以是任何数字

3 个答案:

答案 0 :(得分:4)

这是代码

var r = new Regex(@"Search Results: 1 - 20 of [0-9,]+ for your search criteria");
if (r.IsMatch(x)) {
  // yes, match, do your stuff
}

答案 1 :(得分:2)

你想要这样的东西吗?

Regex rgx = new Regex(@"Search Results: 1 - 20 of ([\d,]+) for your search criteria");

答案 2 :(得分:1)

Search Results: 1 - 20 of ([0-9]+,)+[0-9]+ for your search criteria

相关问题