本文介绍了如果Jmeter中存在多个变量,如何使用正则表达式提取的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果Jmeter中存在多个变量,如何使用正则表达式提取

How to Extract using regular expression if there are multiple variables in Jmeter

步骤:

  1. 我有一个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\=(.+?)\&amp\;name\=Newform\&amp\;Community\=(.+?)\&

模板

$1$$2$

  1. 要验证您的正则表达式提取器,请添加Debug Sampler(右键单击线程组> Add > Sampler > Debug Sampler)

  1. 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_g1c_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中存在多个变量,如何使用正则表达式提取的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-21 03:46