Delvis Echeverria
Delvis Echeverria

Reputation: 109

Regular expressions Extraction Jmeter

I'm trying to extract the following text in the header of a Response:

Location: example.aspx?X+Gy/a4DwC/og==
  1. With the RegEx Location: (.*), I can get this: example.aspx?X+Gy/a4DwC/og==

  2. With the RegEx Location: example.aspx?(.*) I manage to get this: ?X+Gy/a4DwC/og==

But just I need to extract X+Gy/a4DwC/og== without the question mark.

Upvotes: 2

Views: 56

Answers (2)

Jan
Jan

Reputation: 43169

You could use the following pattern:

(?<=[?])(?<query>.*)
# Positive lookbehind looking for a question mark
# start a named capturing group called query, this will hold your output

See a demo on regex101.

Upvotes: 0

Wiktor Stribiżew
Wiktor Stribiżew

Reputation: 626936

You may use a lookbehind to say that you need to match all starting after a ?:

(?<=[?]).*

See regex demo. You may replace * with + to match at least 1 symbol. Use $0$ template with this expression.

Another alternative is using a capturing regex [?](.*) with $1$ template.

Upvotes: 1

Related Questions