根据您对其他响应的 cmets,您实际上只想匹配符合模式 name=\"id\" value=\"###\" 的数字,因此有四种可能性,具体取决于您希望匹配的精确程度。另外,根据您的 cmets,我使用 javascript 作为实现语言。
另外,请注意之前的答案错误地转义了 id 和 value 字符串周围的斜线。
FWIW,我已经测试了以下每个选项:
选项 1:匹配任意数字
//build the pattern
var pattern = /name=\"id\" value=\"([0-9]+)\"/g
//run the regex, after which:
// the full match will be in array_matches[0]
// the matching number will be in array_matches[1]
var array_matches = pattern.exec(strVal);
选项 2:匹配任何 3 位数字
//build the pattern
var pattern = /name=\"id\" value=\"([0-9]{3})\"/g
//run the regex, after which:
// the full match will be in array_matches[0]
// the matching number will be in array_matches[1]
var array_matches = pattern.exec(strVal);
选项 3:匹配特定的 3 位数字范围
//build the pattern; modify to fit your ranges
// This example matches 110-159 and 210-259
var pattern = /name=\"id\" value=\"([1-2][1-5][0-9])\"/g
//run the regex, after which:
// the full match will be in array_matches[0]
// the matching number will be in array_matches[1]
var array_matches = pattern.exec(strVal);
选项 4:匹配特定的 3 位数字
//build the pattern; modify to fit your numbers
// This example matches 217, 218, 219 and 253
var pattern = /name=\"id\" value=\"(217|218|219|253)\"/g
//run the regex, after which:
// the full match will be in array_matches[0]
// the matching number will be in array_matches[1]
var array_matches = pattern.exec(strVal);