Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Regex 正则表达式-如何提取属于指定ID的数字?_Regex_Jmeter - Fatal编程技术网

Regex 正则表达式-如何提取属于指定ID的数字?

Regex 正则表达式-如何提取属于指定ID的数字?,regex,jmeter,Regex,Jmeter,我正在尝试提取我正在输入的ID(即12072)行中出现的数字“1” 在过去的两个小时里,我一直在努力让这个正则表达式工作,但我不知所措。到目前为止,我已经 12072.*?(\d+)(?!.*\d) 但这让我了解了从12072到1的一切。以下是文本: <td id="12072" scope="#999999" bgcolor="#999999" style="width: 65; color:#999999" align="center" onclick="DaySelect(th

我正在尝试提取我正在输入的ID(即12072)行中出现的数字“1”

在过去的两个小时里,我一直在努力让这个正则表达式工作,但我不知所措。到目前为止,我已经

12072.*?(\d+)(?!.*\d) 
但这让我了解了从12072到1的一切。以下是文本:

<td id="12072" scope="#999999" bgcolor="#999999" style="width: 65; color:#999999" align="center"  onclick="DaySelect(this)" title="">1</td>
<td id="12073" scope="#999999" bgcolor="#999999" style="width: 65; color:#999999" align="center"  onclick="DaySelect(this)" title="">1</td>
1
1.
如何匹配指定ID行末尾的数字1,当然有办法做到这一点


非常感谢您的帮助。

您的对手将在第一组

"12072"[^>]*>(\d+)
这里有一个解释

Match the characters “12073” literally «12073»
Match any character that is NOT a “>” «[^>]*»
   Between zero and unlimited times, as many times as possible, giving back as needed (greedy) «*»
Match the character “>” literally «>»
Match the regular expression below and capture its match into backreference number 1 «(\d+)»
   Match a single digit 0..9 «\d+»
      Between one and unlimited times, as many times as possible, giving back as needed (greedy) «+»

你的对手将在第一组

"12072"[^>]*>(\d+)
这里有一个解释

Match the characters “12073” literally «12073»
Match any character that is NOT a “>” «[^>]*»
   Between zero and unlimited times, as many times as possible, giving back as needed (greedy) «*»
Match the character “>” literally «>»
Match the regular expression below and capture its match into backreference number 1 «(\d+)»
   Match a single digit 0..9 «\d+»
      Between one and unlimited times, as many times as possible, giving back as needed (greedy) «+»
“12072”[^>]+\>([^\可能不需要在jmeter中转义。如果不需要,请删除前导斜杠。

“12072”[^>]+\>([^\可能不需要在jmeter中转义。如果不需要,请删除前导斜杠。

您可以更好地使用xpath查询,如

//td[@id='${id}']/text()
其中,
${id}
是将jmeter变量设置为您需要的值(例如12072),还是简单地设置为

//td[@id='12072']/text()
如果你不需要参数化

注意:请确保在XPath提取器的控制面板上选中了该选项—这是使用XPath处理html响应所必需的。

您可以尝试使用类似XPath的XPath查询

//td[@id='${id}']/text()
其中,
${id}
是将jmeter变量设置为您需要的值(例如12072),还是简单地设置为

//td[@id='12072']/text()
如果你不需要参数化


注意:请确保在XPath提取器的控制面板上选中了该选项-这是使用XPath处理html响应所必需的。

您使用的是什么语言,或者jmeter是一种语言?现在要测试它。jmeter实际上是一个负载测试工具。我使用的是JMeters内置正则表达式库:“Jakarta ORO Java类是一组文本处理Java类,提供Perl5兼容的正则表达式、类似AWK的正则表达式、全局表达式和用于执行替换、拆分、过滤文件名等的实用程序类。“您使用的是哪种语言?或者jmeter是一种语言?现在要测试它。jmeter实际上是一种负载测试工具。我使用的是JMeters内置的正则表达式库:Jakarta ORO Java类是一组文本处理Java类,提供Perl5兼容的正则表达式、类似AWK的正则表达式、全局表达式以及用于执行替换、拆分、过滤文件名等的实用程序类