简体   繁体   中英

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?

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

The relevant regular expression would be something like:

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

Demo:

JMeter 正则表达式演示

References:

尝试使用这个正则表达式:

\w+(?='\))

Regex would be:

, '([^']+?)');

Configuration would be:

稀土配置

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM