简体   繁体   English

Jmeter中的正则表达式提取器

[英]Regular Expression Extractor in Jmeter

I have this response in HTTP request as below 我在HTTP请求中有此响应,如下所示

href="index.php?module=Meetings&action=DetailView&record=ed51c2d9-1958-bd61-cce1-509d30ccd4ac">

I want to get the value of "record", but when I set 我想获得“记录”的价值,但是当我设定时

Regular Expression : record=(.+?)

only "e" is returned. 只返回“e”。 What do I need to do instead? 我需要做什么呢?

Well the regular expression consumes as little as possible (due to the ? ). 那么正则表达式消耗尽可能少(由于? )。 Hence, it is satisfied after taking in the first character. 因此,在接受第一个角色后,它会得到满足。 You should probably rather make it greedy and restrict the possible characters (so that it cannot go past the end of the parameter): 您可能更应该使其贪婪并限制可能的字符(以便它不能超过参数的末尾):

record=([a-f0-9-]+)

If you do not know which characters are allowed as the parameter's value, you could also say, consume everything but ampersands and quotes: 如果您不知道允许哪些字符作为参数的值,您还可以说,除了&符号和引号之外的所有内容:

record=([^"'&]+)

Depending on where you use it, you might need to escape one of the quotes with a backslash. 根据您使用它的位置,您可能需要使用反斜杠转义其中一个引号。

The given text 给定的文字

href="index.php?module=Meetings&action=DetailView&record=ed51c2d9-1958-bd61-cce1-509d30ccd4ac">

Regular Expression to get the record values from the given text values 正则表达式从给定的文本值中获取记录值

record=(.+)"

Regular Expression gets the following record values 正则表达式获取以下记录值

record=ed51c2d9-1958-bd61-cce1-509d30ccd4ac"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM