简体   繁体   English

在 JMeter 中,我需要提取特定的正则表达式

[英]In JMeter I need to extract a specific Regular Expression

In the following String:在以下字符串中:

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

I need to extract "QW233Cdse"我需要提取"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:与您的情况一样,“Events()”似乎是一个静态文本,在圆括号中包含动态值,因此为了生成正则表达式,您需要保留 'Events()' 文本并在圆括号中添加表达式如以下所说的:

Test String: Events('1234', '123456', '', 'QW233Cdse');测试字符串: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:配置将是:

稀土配置

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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