Aajan
Aajan

Reputation: 937

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.

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

Answers (3)

Kaushlendra Jha
Kaushlendra Jha

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

vks
vks

Reputation: 67978

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

You can simply use this.See demo.

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

Upvotes: 3

karthik manchala
karthik manchala

Reputation: 13640

You can use the following:

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

See RegEX DEMO

Upvotes: 1

Related Questions