如何在Jmeter中使用正则表达式提取多个值 [英] How to extract multiple values with a regular expression in Jmeter
问题描述
我正在使用jmeter运行测试,并且需要使用正则表达式进行提取:
I am running tests with jmeter and I need to extract with a Regular Expression:
insertar?sIws2kyXGJJA_01==
insertar?sIws2kyXGJJA_02==
在以下字符串中:
[\"EMBPAGE1_00010001\",\"**insertar?sIws2kyXGJJA_01==**\",1,100,\"%\",300,\"px\",0,\"center\",\"\",\"[\"EMBPAGE1_00010002\",\"**insertar?sIws2kyXGJJA_02==**\",1,100,\"%\",300,\"px\",0,\"center\",\"\",\"
推荐答案
使用超级秘密运算符(否定匹配N)
Use super secret operator (Negative match N)
UPD:G2-在我的示例中,因为我从每次遭遇中提取了两组. 每次相遇在g1和g2中都是"uuid",第二部分是我需要的第二部分. 这就是为什么$ 2 $模板和g2.如果您在一个小组中遇到,您很可能会使用$ 1 $模板,它将所有遇到的事情放到g1中. 如果您有一个匹配组,则实际上根本不需要_gN结尾. 要了解更多有关组提取后的变量的信息,请添加"Debug PostProcessor"并检查TreeView中的输出.
UPD: G2 - is in my example, as I extract two groups from each encounter. each encounter is "uuid" in g1 and g2 is second part I need second part here. that's why $2$ template and g2. If your encounters in one group you ll most likely use $1$ template that will place all encounters into g1. If you have one match group you don't actually need _gN ending at all. To understand more the variables after group extraction add a "Debug PostProcessor" and inspect output in TreeView.
两个人都知道,"For Each"之类的控制元素可以理解组,并且可以使用诸如regexUUID_之类的前缀并逐步执行.在大多数情况下,提取之后是下一步.
It nice two know that control elements like "For each" understand groups and can work with prefix like regexUUID_ and walk through. In most cases it's next you do after extraction.
UPD2.正在讨论的正则表达式的原始版本(insertar \?sIws2kyXGJJA_ \ d *)==([[^ [] *) 模板$ 1 $$ 2 $ 您将在g1组中拥有第一部分,在g2组中拥有第二部分
UPD2. primitive version of regexp in question (insertar\?sIws2kyXGJJA_\d*)==([^[]*) with template $1$$2$ you ll have the first parts in g1 group and the second parts in g2
这篇关于如何在Jmeter中使用正则表达式提取多个值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!