-1

I am trying to extract the location from a POST in jmeter using the Regex Expression Extractor. The header looks like the below

HTTP/1.1 201 Created
Transfer-Encoding: chunked
groopId: ID-99-Inc-07-12300-2650126876118-1-236
User-Agent: RestClient-Tool
Date: Thu, 14 Feb 2019 13:57:23 GMT
Location: v2/TestData/12sff-13343e-dff3444455
Content-Type: text/plain; charset=UTF-8

I need theLocation: v2/TestData/12sff-13343e-dff3444455 .

enter image description here

I am struggling because I am not quite sure how to create the regex I need.

user6248190
  • 987
  • 1
  • 10
  • 19
  • 1
    Possible duplicate of [Learning Regular Expressions](https://stackoverflow.com/questions/4736/learning-regular-expressions) – Biffen Feb 14 '19 at 14:54
  • 1
    @Biffen your link is useful, but it's not really a duplicate... – Oram Feb 14 '19 at 14:58
  • But it is a dupe of [What do 'lazy' and 'greedy' mean in the context of regular expressions?](https://stackoverflow.com/questions/2301285/what-do-lazy-and-greedy-mean-in-the-context-of-regular-expressions) (after adding the screenshot showing what the real problem is) – Wiktor Stribiżew Feb 14 '19 at 15:05
  • @WiktorStribiżew tbh honest it was a bit of confirmation of asking how to use the regular expression extractor in Jmeter and confirming whether the regex was correct – user6248190 Feb 14 '19 at 15:26
  • You can confirm at http://regex101.com - it explains all the regex patterns automatically and in great detail. – Wiktor Stribiżew Feb 14 '19 at 15:27

1 Answers1

2
  1. Add Regular Expression Extractor as a child of the request which returns above headers
  2. Configure it as follows:

    • Apply to: depending on where this Location header comes from
    • Field to check: Response Headers
    • Regular Expression: Location: (.*)
    • Template: $1$

      enter image description here

  3. That's it, you should be able to access the extracted value as ${location} where required.

References:

Dmitri T
  • 119,313
  • 3
  • 56
  • 104