Search code examples
regexjmeterperformance-testing

In JMeter I need to extract a specific Regular Expression


In the following String:

Events('1234', '123456', '', 'QW233Cdse');

I need to extract "QW233Cdse"

Any suggestion?


Solution

  • When we are working with regular expressions then its very important that we should look for the static text in the test string that can help to create a strong regular expression.

    As in your case, "Events()" seems to be a static text containing dynamic value in the round parenthesis so in order to generate the regular expression you need to keep 'Events()' text and add the expression in the round parenthesis as mentioned below:

    Test String: Events('1234', '123456', '', 'QW233Cdse');

    Regular Expression can be:

    • Events(.'(.)');
    • Events(.* '(.+?)');

    Note: The backslash before round parentheses would avoid interpreting the round braces as unescaped character. For example, a parenthesis "(" begins the definition of a quantifier, but the leading backslash of parenthesis "(" indicates that the regular expression should match the parenthesis.

    Regular expression is most important item to learn when you are working with load testing tools and you can refer to below blog post to get more information on regular expression:

    Let me know if you have any further question