-1

I have response from previous request. I am trying to use regular expression to get the required text. My response is given below

{
  "screen": {
    "heading": "HEADING",
    "content": {
      "lines": [
        "Scan the source CBSE. "
      ]
    },
    "prompt": {
      "default": "",
      "display_value": "HEADING",
      "masked": {
        "on": "FALSE",
        "char": "*"
      }
    }
  }
}

In the above json response i am trying to extract the word CBSE . I am using the below regular expression in regex tester - (?<=Scan the source ).*(?=. ")

But when i check the same in JMeter i am getting error and it is not saved in the variable too.

Error in JMeter: org.apache.oro.text.MalformedCachePatternException: Invalid expression: (?<=Scan the source ).*(?=. ") Sequence (?<...) not recognized

  • Does this answer your question? [Regex: Extract string between two strings. No apparent delimitors](https://stackoverflow.com/questions/40795568/regex-extract-string-between-two-strings-no-apparent-delimitors) – Ryszard Czech Nov 18 '21 at 22:28

1 Answers1

-1

I don't think your regex is valid for Jakarta ORO syntax, try something more simple like:

"Scan the source\s*(.+?)\. "

enter image description here

Also be aware that JMeter provides Boundary Extractor so it's sufficient to just supply "left" and "right" boundaries and JMeter will get everything in-between:

enter image description here

Moreover this approach consumes less resources, see The Boundary Extractor vs. the Regular Expression Extractor in JMeter article for more information.

Dmitri T
  • 159,985
  • 5
  • 83
  • 133