Jmeter组件4. Regular Expression Extractor

位置:Post-Processors - Regular Expression Extractor

所谓的Post-Processors直译为后处理器,意思是在域内所有Sampler执行完后才会执行,所以如果你想只对某个Sampler生效的话,那就加成子对象

这个组件可以用来做关联,非常有用

Apply to,作用域,主要作用在于是否作用在sub-sampler

Field to check,分的很细,意思是你打算去哪里取值

Reference Name,变量名,取值后存储的对象名,可以用作${变量名},另外${变量名}_g#,#代表第几组,g0表示完全匹配,包含整个字符串,g1代表从第对括号开始匹配,g2表示第二对括号开始的匹配

Regular Expression: 正则表达式

Template: $1$指向group 1,即匹配第一个正则表达式括号内的内容,依次类推

Match No: 选择第几次匹配到的值,有可能一个Sampler下面匹配到多个值,这时这个变量就可以用到,0代表随机取,可以用在每次取到的值是一样的情况下

Default Value: 如果没有匹配到的默认值,建议设置,可以快速定位问题

例子

第一个请求里有个XSRF-TOKEN在response header里面

需要在第二个请求里用到,我在第二个请求的header manager里面定义了一个叫token的变量

将Regular Expression Extractor加为第一个请求的子对象

这样就可以执行成功了,如果去掉这里的Regular Expression Extractor,则会执行失败,因为这里的XSRF-TOKEN对象会一直变化,所以只有在第一个请求执行完了,去response header里动态地去取

打印下其中的变量

token_g=1 表示一组匹配,g0不算

token_g0,一个全量的匹配

token_g1,第一个括号内的匹配

因为只有一组匹配,所以这里Match No放0,随机只能取到唯一的一组值,g0不算

时间: 2024-08-01 11:34:24

Jmeter组件4. Regular Expression Extractor的相关文章

Regular Expression Extractor (转)

Regular Expression Extractor是JMeter中的另一个概念—Post-processor,它的作用是得到HTTP响应后,对结果(比如一个html标签页面的内容或json输出数据等)进行处理,通过regular expression抽取字符值,存成一个变量给后面的Sampler使用. 例如在Click Table(afterSelectTable_ajax.action)这个Sampler执行完一次HTTP Request之后得到如下的HTTP Response(一个js

Jmeter 正则表达式提取器详解(Regular Expression Exactor)

Jmeter 正则表达式提取器详解(Regular Expression Exactor) Name(名称):随意设置,最好有业务意义. Comments(注释):随意设置,可以为空 Apply to(应用范围): Main samples and sub-samples:匹配范围包括当前父取样器并覆盖至子取样器. Main samples only:只匹配当前父取样器 Sub-samples only:仅匹配子取样器 Jmeter Variable Name to use:支持对Jemter变

LeetCode 10. Regular Expression Matching

https://leetcode.com/problems/regular-expression-matching/description/ Implement regular expression matching with support for '.' and '*'. '.' Matches any single character. '*' Matches zero or more of the preceding element. The matching should cover

Python正则表达式Regular Expression基本用法

资料来源:http://blog.csdn.net/whycadi/article/details/2011046   直接从网上资料转载过来,作为自己的参考.这个写的很清楚.先拿来看看. 1.正则表达式re模块的基本函数. (1)findall函数的用法 findall(rule,target[,flag])是在目标字符串中找到符合规则的字符串.参数说明:rule表示规则,target表示目标字符串,[,flag]表示的是规则选项.返回的结果是一个列表.若没找到符合的,是一个空列表. 如: 因

Java [leetcode 10] Regular Expression Matching

问题描述: Implement regular expression matching with support for '.' and '*'. '.' Matches any single character. '*' Matches zero or more of the preceding element. http://i.cnblogs.com/EditPosts.aspx?opt=1 The matching should cover the entire input string

【leetcode】Regular Expression Matching (hard) ★

Implement regular expression matching with support for '.' and '*'. '.' Matches any single character. '*' Matches zero or more of the preceding element. The matching should cover the entire input string (not partial). The function prototype should be

[LeetCode] Regular Expression Matching(递归)

Implement regular expression matching with support for '.' and '*'. '.' Matches any single character. '*' Matches zero or more of the preceding element. The matching should cover the entire input string (not partial). The function prototype should be

Python正则表达式 re(regular expression)

1. 点. .: 代表一个字符 (这个跟linux的正则表达式是不同的,那里.代表的是后面字符的一次或0次出现) 2. 转义 \\ 或者 r'\': 如 r'python\.org' (对.符号的转义) 3. ^ 非或叫做排除 如[^abc]: 任何以非a,b,c的字符 4. | 选择符 如python|perl (从python和perl选择一个) 也可以: p(ython|erl) 5. ? 可选项 如: r'(http://)?(www\.)?python\.org' (http://和w

[LeetCode] 10. Regular Expression Matching ☆☆☆☆☆

Implement regular expression matching with support for '.' and '*'. '.' Matches any single character. '*' Matches zero or more of the preceding element. The matching should cover the entire input string (not partial). The function prototype should be