如何对jmeter中的正则表达式进行参数化?

时间:2022-06-01 12:44:13

I have a variable

我有一个变量

announcementName= test

I am trying to use regEx Extractor to match an expression in jmeter.

我正在尝试使用regEx提取器来匹配jmeter中的表达式。

I am able to match data with the below expression.

我能够将数据与下面的表达式匹配。

{"id":(.*?),"announcementName":"test",

However I am unable to pass test as a variable to the same expression

但是,我不能通过测试作为一个变量到相同的表达式

 {"id":(.*?),"announcementName":"${announcementName}",

I am unable to match anything with the above regEx matching.

我无法匹配上述regEx匹配的任何内容。

Can someone please let me know on how to pass parameters to RegEx Extractor in Jmeter.

谁能告诉我如何在Jmeter中向RegEx提取器传递参数。

2 个解决方案

#1


2  

As per my experience, if you try this approach in listener to verify whether correlation is working or not than obviously it's not going to work.

根据我的经验,如果您在listener中尝试这种方法来验证相关性是否有效,显然它不会有效。

But if you are passing this directly in reg ex extractor and trigger the script then it should work provided the variable does not contain any special character like (.,?) etc. (As you mentioned test as value so seems you took an example to display here but actual value is something else, so please check actual value once again to confirm it's a simple string without any special characters)

但如果你通过这个直接在注册前提取器和触发脚本然后它应该工作提供了变量不包含任何特殊字符(?)等。(正如你所提到的测试值,因此似乎你用一个例子来显示但实际价值是别的东西,所以请检查实际价值再次确认这是一个简单的字符串没有任何特殊字符)

#2


0  

You can check with __V() function.
i.e.

{"id":(.*?),"announcementName":"${__V(${announcementName})}",

{ " id ":(. * ?),“announcementName”:“$ { __V($ { announcementName })}”,

#1


2  

As per my experience, if you try this approach in listener to verify whether correlation is working or not than obviously it's not going to work.

根据我的经验,如果您在listener中尝试这种方法来验证相关性是否有效,显然它不会有效。

But if you are passing this directly in reg ex extractor and trigger the script then it should work provided the variable does not contain any special character like (.,?) etc. (As you mentioned test as value so seems you took an example to display here but actual value is something else, so please check actual value once again to confirm it's a simple string without any special characters)

但如果你通过这个直接在注册前提取器和触发脚本然后它应该工作提供了变量不包含任何特殊字符(?)等。(正如你所提到的测试值,因此似乎你用一个例子来显示但实际价值是别的东西,所以请检查实际价值再次确认这是一个简单的字符串没有任何特殊字符)

#2


0  

You can check with __V() function.
i.e.

{"id":(.*?),"announcementName":"${__V(${announcementName})}",

{ " id ":(. * ?),“announcementName”:“$ { __V($ { announcementName })}”,