简体   繁体   English

Jmeter正则表达式提取具有不同边界的数字

[英]Jmeter Regular Expression To Extract A Number Having Varying Boundaries

I need to extract one number from a Jmeter response using regular expression extractor as part of correlation. 我需要使用正则表达式提取器从Jmeter响应中提取一个数字作为相关的一部分。

Scenario is: 场景是:

<span>Abc456ABC</span>
If I use <span>(.*?)</span>, then I will get "Abc456ABC".
If I use <span>Abc(.*?)ABC</span>, then I will get "456".

But the left and right boundary can vary.The input can be like: Abcdef789ABCgh 但是左右边界可以变化。输入可以是:Abcdef789ABCgh

I need only the number[In last case it is "789"]. 我只需要数字[在最后一种情况下它是“789”]。 Please suggest the suitable regular expression extractor. 请建议合适的正则表达式提取器。

Thanks In Advance.. 提前致谢..

<span>.*?([0-9]+).*?</span>

You can simply use this.See demo. 你可以简单地使用它。参见演示。

https://regex101.com/r/uE6jQ1/11 https://regex101.com/r/uE6jQ1/11

You can use the following: 您可以使用以下内容:

<span>\D+(\d+)\D+</span>

See RegEX DEMO 请参阅RegEX DEMO

you can use <span>([\\w]+)(\\d+)([\\w+])</span> , It'll surely work 你可以使用<span>([\\w]+)(\\d+)([\\w+])</span> ,它肯定会起作用

But use $2$ as template in regular expression extractor 但是在正则表达式提取器中使用$ 2 $作为模板

([\\w]+):it will capture all words and (\\d+): will take care of digits for you ([\\ w] +):它将捕获所有单词和(\\ d +):将为您处理数字

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM