简体   繁体   English

使用 Jmeter 中的正则表达式从 URL 中提取令牌

[英]Extract token from URL resonse with Regular expression in Jmeter

Here is the URL returned:这是返回的 URL:

https://192.168.1.1:9006/payinterface/ThreeDSChecker/Check3DS?token=707087d7-7b75-42bc-8564-69a13c403b8a&MID=0000&TID=000000" , https://192.168.1.1:9006/payinterface/ThreeDSChecker/Check3DS?token=707087d7-7b75-42bc-8564-69a13c403b8a&MID=0000&TID=000000" ,

I need to extract the token value, When I use this expression token=(.*&M+) I got the below values我需要提取令牌值,当我使用这个表达式 token=(.*&M+) 我得到以下值

Match count: 1
Match[1][0]=token=707087d7-7b75-42bc-8564-69a13c403b8a&M
Match[1][1]=707087d7-7b75-42bc-8564-69a13c403b8a&M

I need to get only value of the token without the "&M" in the end我只需要得到令牌的价值,最后没有“&M”

Move M+ after brackets to get value until &M在括号后移动M+以获取值,直到 &M

token=(.*)&M

I don't think you even need the regular expressions here, you can go for the Boundary Extractor and provide token= as the left boundary and & as the right boundary:我认为您甚至不需要这里的正则表达式,您可以将 go 用于边界提取器并提供token=作为左边界和&作为右边界:

在此处输入图像描述

It would be easier, faster and consume less resources.它会更容易、更快并且消耗更少的资源。

More information: The Boundary Extractor vs. the Regular Expression Extractor in JMeter更多信息: JMeter 中的边界提取器与正则表达式提取器

If you want to continue with regular expressions you can go for:如果你想继续使用正则表达式,你可以 go 为:

token=(.+?)&

在此处输入图像描述

or if you're looking for a GUID -like structure:或者,如果您正在寻找类似GUID的结构:

([A-Fa-f0-9]{8}[\-][A-Fa-f0-9]{4}[\-][A-Fa-f0-9]{4}[\-][A-Fa-f0-9]{4}[\-]([A-Fa-f0-9]){12})

在此处输入图像描述

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

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