Reputation: 937
I need to extract one number from a Jmeter response using regular expression extractor as part of correlation.
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
I need only the number[In last case it is "789"]. Please suggest the suitable regular expression extractor.
Thanks In Advance..
Upvotes: 4
Views: 3515
Reputation: 396
you can use <span>([\w]+)(\d+)([\w+])</span>
, It'll surely work
But use $2$ as template in regular expression extractor
([\w]+):it will capture all words and (\d+): will take care of digits for you
Upvotes: 1
Reputation: 67978
<span>.*?([0-9]+).*?</span>
You can simply use this.See demo.
https://regex101.com/r/uE6jQ1/11
Upvotes: 3
Reputation: 13640
You can use the following:
<span>\D+(\d+)\D+</span>
See RegEX DEMO
Upvotes: 1