arm
arm

Reputation: 451

Jmeter regular expression extractor not extracting what I want

I have a link in my Request -

example.com/people/3176972 

and my regular expression extractor is-

Regular expression: example.com/people/(.+?)

Template: $1$

Match no: 1

but it is only extracting only 3. I want to extract 3176972 number.

What am I doing wrong?

Upvotes: 0

Views: 345

Answers (3)

victor sosa
victor sosa

Reputation: 899

You should try this regular expression:

[0-9]+

Upvotes: 1

Dmitri T
Dmitri T

Reputation: 168157

Amend your regular expression to look like example.com/people/(.*) or example.com/people/(\d+) as your regex stops after first match.

See Regular Expressions chapter of JMeter's User Manual for more information on JMeter Regular Expressions.

Convenient way of testing regular expressions is using "RegExp Tester" mode of the View Results Tree listener.

RegExp Tester

Check out How to debug your Apache JMeter script guide for more information on different debugging techniques for JMeter tests.

Upvotes: 0

timbre timbre
timbre timbre

Reputation: 13995

If you want to retrieve anything after the last slash, then just remove question mark from your expression:

example.com/people/(.+)

(question mark tells it to be non-greedy, hence it's taking 1 character).

If the last portion is always numeric, use

example.com/people/([0-9]+)

Upvotes: 1

Related Questions