在jmeter正则表达式提取器中制作通用正则表达式

时间:2022-02-10 13:39:11

I have the following code snippet in my html response:

我在html响应中有以下代码片段:

003cdiv  id\u003d\"d1f15ddf10691ed7%2?604?-1form

I extract the value of id which is

我提取id的值

d1f15ddf10691ed7%2?604?-1

by the regular expression

通过正则表达式

003cdiv  id\\u003d\\"(.+?)form

My problem is, sometimes, the generated value becomes

我的问题是,有时,生成的值变为

d1f15ddf10691ed7%2?604?-1EVENT_ERROR

I know that this is because of an error but is it possible that I will still be able to get the id value using a more (somehow) generic way of a regular expression?

我知道这是因为一个错误,但我是否仍然可以使用更多(某种方式)正则表达式的通用方式来获取id值?

1 个解决方案

#1


2  

Please try to update your regular expression as below:

请尝试更新您的正则表达式,如下所示:

id\\u003d\\"(.+?)(form|EVENT_ERROR)

Make sure, the template value of your Regular Expression Extractor is $1$ to get the first group value.

确保,正则表达式提取器的模板值为$ 1 $以获取第一个组值。

I hope this help you.

我希望这对你有帮助。

#1


2  

Please try to update your regular expression as below:

请尝试更新您的正则表达式,如下所示:

id\\u003d\\"(.+?)(form|EVENT_ERROR)

Make sure, the template value of your Regular Expression Extractor is $1$ to get the first group value.

确保,正则表达式提取器的模板值为$ 1 $以获取第一个组值。

I hope this help you.

我希望这对你有帮助。