-1

I am playing with regex in Jmeter, and with some reason it returns an error for the pattern (?<=lang=")(.+?)(?=")

I did request to www.microsoft.com/en-us where I got

<!DOCTYPE HTML>

<html lang="en-US" dir="ltr">
<head>

So I wanted to get en-US but I got the error when I use inside Regular Expression Extractor this "?<=". What is really weird as it works properly in python, and in view results Tree element when I use to search in the Response body with regular exp. Who faced a simular issue, and how to fix it?

  • 1
    Obligatory link: [You can't parse \[X\]HTML with regex.](https://stackoverflow.com/a/1732454) – InSync Jul 09 '23 at 15:58
  • 2
    Jmeter [doesn't support lookbehind](https://jmeter.apache.org/usermanual/regular_expressions.html#meta_chars). Perhaps you can match all of them, then extract the first group: [`lang="(.+?)"`](https://regex101.com/r/3hdvva/1). However, parsing HTML with regex is a no-no. I don't know Jmeter, but I believe that there are better ways to achieve the same thing. – InSync Jul 09 '23 at 16:09
  • Don't worry, in the current case I can use regex to parse the response(here it will be like a text), the problem is "Note that (?<=regexp) - lookbehind - is not supported.". That I missed. Thanks, @InSync, next time I will go to check the documentation first... – Kirill Kiselev Jul 09 '23 at 16:23

1 Answers1

0

The issue is that (?<=regexp) - - is not supported in Jmeter. So the only way is to use groups lookbehind