[英]JMeter Regular Expression Extractor to extract custom header “access-token”
I have bellow response header that is giving me the problem when extracted using Regular Expression Extractor. 我有波纹管响应标头,使用正则表达式提取器提取该问题时出现问题。 To keep to story short, after troubleshooting I come up with a solution that works but is not perfect.
简而言之,在进行故障排除后,我提出了一个可行但不完美的解决方案。
Response headers:
HTTP/1.1 200 OK
Vary: Origin, Accept-Encoding
Access-Control-Allow-Credentials: true
X-XSS-Protection: 1; mode=block
X-Frame-Options: DENY
X-Download-Options: noopen
X-Content-Type-Options: nosniff
access-token: GAbnLmcDzT4j5INPkSGwdbQzZIIFIaJoy4wBnmNUF4NEgGB11IfzTAMdqXyxIhAZ
Access-Control-Expose-Headers: access-token
Content-Type: application/json; charset=utf-8
Regular Expression : access-token: (.+?)\\n 正则表达式 :访问令牌:(。+?)\\ n
Template : $1$ 模板 :$ 1 $
Refer to below picture on why I think the solution is wrong. 请参阅下图,以了解为什么我认为解决方案是错误的。 Extracted token is represented by multiple variable as
result_token, result_token_g, result_token_g0, result_token_g1
: 提取的令牌由多个变量表示为
result_token, result_token_g, result_token_g0, result_token_g1
:
What is the correct Regular expression and template to get only the token. 什么是仅获取令牌的正确正则表达式和模板?
TIA! TIA!
UPDATE: 更新:
Bellow excerpt from Regular Expression Extractor Doc actually help me better understand this question. 正则表达式提取器文档的 Bellow摘录实际上帮助我更好地理解了这个问题。
If the match number is set to a negative number, then all the possible matches in the sampler data are processed.
如果匹配编号设置为负数,则将处理采样器数据中所有可能的匹配。 The variables are set as follows:
变量设置如下:
refName_matchNr - the number of matches found;
refName_matchNr-找到的匹配项数; could be 0
可能是0
refName_n, where n = 1,2,3 etc - the strings as generated by the template
refName_n,其中n = 1,2,3等-模板生成的字符串
refName_n_gm, where m=0,1,2 - the groups for match n
refName_n_gm,其中m = 0,1,2-匹配项n的组
refName - always set to the actual template value if a match is found, otherwise, the default value.
refName-如果找到匹配项,则始终设置为实际模板值,否则为默认值。
Use this: 用这个:
Regular Expression : access-token: (.\w*)
Template: $1$
Match No: 1
DefaultValue: Not found
It seems to me, that you are getting it right; 在我看来,你做对了。 result-token_g1 contains the intended capture, and it is replicated via your template to result-token.
result-token_g1包含预期的捕获,并通过您的模板将其复制到结果令牌。
Don't worry about result-token_g0; 不用担心result-token_g0; it's supposed to show the complete match: capture AND context.
它应该显示出完整的匹配:捕获和上下文。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.