无法通过正则表达式提取从标头中的URL中提取GUID

时间:2015-03-05 22:49:39

标签: regex http-headers jmeter

我在从标头中的位置提取GUID时遇到问题。我试过跟随,它似乎根本没有提取。

Response headers:
HTTP/1.1 201 Created
Content-Length: 99
Content-Type: application/json; charset=utf-8
Location: https://hello.com/books/category/cdeacb91af9f4faca842714c4ee9be45
Server: Microsoft-IIS/8.5
X-Powered-By: ASP.NET
Date: Thu, 05 Mar 2015 22:29:37 GMT

我尝试使用正则表达式,它只是不会提取该GUID。在大多数情况下,我能够提取任何我想要的东西(。+?)

Location: https://hello.com/books/category/(?s)(.*?)$
Location: https://hello.com/books/category/(.+?)

感谢。

2 个答案:

答案 0 :(得分:1)

您只需使用字符类:

Location: https://hello.com/books/category/([0-9a-fA-F]{32})

[0-9a-fA-F]表示A和F之间的所有数字和字母,包括大写和小写。

答案 1 :(得分:0)

如果提供了正确的边界,您的(.+?)正则表达式将正常工作。

尝试将其更改为

Location: https://hello.com/books/category/(.*)

它应该做的伎俩

另外,请不要忘记将“要检查的字段”更改为“响应标头”,因为正则表达式将无法在响应正文中查找“位置”标头。

有关详细信息,请参阅Using RegEx (Regular Expression Extractor) with JMeter指南。