问题描述
如果Jmeter中存在多个变量,如何使用正则表达式提取
How to Extract using regular expression if there are multiple variables in Jmeter
步骤:
- 我有一个URL,其中有2个变量.我想提取第二个变量,即"communityID".任何人都可以帮我做正则表达式,我应该在jmeter中使用它来提取该变量
屏幕截图已附加在此处输入图片描述
推荐答案
请为您的Regular Expression Extractor
使用以下配置.这将提取两个值并将其分别存储在<your-reference-name>_g1
和<your-reference-name>_g2
中.
Please use the below configuration for your Regular Expression Extractor
. This will extract two values and store it in the <your-reference-name>_g1
and <your-reference-name>_g2
respectively.
正则表达式为
Public/FormsPreview.aspx\?Id\=(.+?)\&\;name\=Newform\&\;Community\=(.+?)\&
模板为
$1$$2$
-
要验证您的正则表达式提取器,请添加
Debug Sampler
(右键单击线程组>Add > Sampler > Debug Sampler
)
To validate your regular expression extractor, add a
Debug Sampler
(Right Click on your thread group >Add > Sampler > Debug Sampler
)
执行测试计划
在View Results Tree
中,您可以看到c_ID_g1
和c_ID_2
值,如下所示.
In View Results Tree
you can see the c_ID_g1
and c_ID_2
value as shown below.
您可以使用${c_ID_g1}
和${c_ID_2}
这篇关于如果Jmeter中存在多个变量,如何使用正则表达式提取的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!