如何从JMeter中使用正则表达式提取器提取的多个值中提取单个Header值?

时间:2018-09-13 10:41:31

标签: regex jmeter

我需要提取此突出显示的值作为授权令牌:

Response headers:
HTTP/1.1 200 OK
Server: GlassFish Server Open Source Edition  4.1 
X-Powered-By: Servlet/3.1 JSP/2.3 (GlassFish Server Open Source Edition  4.1  Java/Oracle Corporation/1.8)
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: GET, POST, DELETE, PUT, OPTIONS
Access-Control-Allow-Headers: Content-Type, Authorization
Access-Control-Expose-Headers: Authorization
Authorization: **eyJhbGciOiJkaXIiLCJlbmMiOiJBMTI4Q0JDLUhTMjU2IiwiY3R5IjoiSldUIn0..ghNqO8N_J_y6FrxTPf03Aw.UwbOxNenbLL8qxoD89AY0Z89190AbiJh6xVlF20RLA3XN5orf3qX9AXoNNSf_qzj3dcu2G5RVdW9DZ2ERez0HEvMkYj871nvDoca4-V1WaeAOkSI3b72UbMoWA4RLnIfAHY64ELJJowXNAS5m0K8MePzHXtAbsQYR0F_jPlPwKIUozOhA4idbMy_YjmmYq6s4PEzM-FURJJVmvO9H7OneXwR01e2S5TVb8AUOVkEk_BeRz5oUsQEl3orb-5it-lmd6upDR_DZqsVJxdlrtH57QexhNZPhLuISCk3YeN_pfXqE7RCv6UrUibSYLSAzVkg3A5TLcRoLtf3Es5e4ubh0RVoCElU1gLBVRQCc2INAdFLBDpqchZgavm2RllsDp9c1AQTv8pOWrNqMX2qQUO_uXF9JZpeJP8YnAC7e1XXtF3DWX-9waXg_g2JrbKxGLu3xTGau5g0IvL5DCTNR4uCIfVgTsS8tBbQKSBgN07qJOgB8prM_a5dAE5Y6F3Rd12-YXC37zwIngYWQ7ka_pOKdB98g6xXOKLWeltuZRvpqyQ32CYMKQXJpwubUh0xWAdND0kOQHj56Kyv2zGy2eOazS5v_68PrY4OYTqKBUEeh_AhO1TUYWj3X9vkDtcKye03d_nArxMstoHkaRE-3dwB3DmbYOKtGmfivQ1dwdW7dAEpj4zsuK49wKt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QAlFfjWp3YaewPdvN3lXDLfN9iaW_voSFX_vv7OYDdU24l8ZaPn6fAJ5WcjlGtCFUPLIPHXGiBZI2EO-n4MZ9ftFJAWYk3VCiXjnRvP1Cqd2m_SuPP-GCUzEF2p1NnqsXZ4Q57YeUBCIydSNa02a4Ss1Ab4t2sg_hLqj0SRUith6oho-HB5w65-5BlepuymJPgq0b1YqpSVnuyAgyiyYQNE9LctNgms2AQeSw4QVMdyTFajf2-fry0CL8WqOad1bfo64TCrpVE28CwVroJ-t_YKI_w1NROzy_TRiRmmmtICvVurfmwtQB4oPgc7wlS2UDrppEvnQ_GeBeMEXFqO_EH-GHrugGmi33iz3ZrILdHJJH_O1eKa6EOREZ9mvJ3aiR23zagp07qZ7lOSCz_GIFY8S3hBQNgfYuZCYhWiaJGDkMwRsqG8_6o08P4sHJMLP2UTy6B_JNVvzDFlWo3FFXxESKdA2hyRe2Z6Y8C9aNgfpP7YrpM8rDk_UehyUwGBuYMgxCd3R9AeK7hkX7MNYB2rPl3dUQnVZiAaXkgE-YLtjN_e9QUy6TlebrF2-FEpN9OhTYi-WbEpSsagVm717IB3xBo7f1RFt5i_lxf2fuqAa_I5Lo8qU_bD8M_kZCL4Sh2bE2i8wkbTbuHnF1Gtaj6i5iuLSx_6q4anSbaxqSTWhaym5VDWTksV1cr7PJsga_3MPic26EZc1tlTbmVjeDmoHdSv99f1GDBK2hogqSrud-7gbMMQppofC8-7pjlEL_z-9_0oKlHhHVXCYg0yiQqk_w07-CfJ4cehU1LeC6nu-6NyU1iGVmJumxIkHT1FCa6ZPYRBcWGSw-MjBNp0l3l3jIOfsSWfoLOQVmbKze1Br4rHuB922J0Dwh8.0YAiHJMnOfXFeATSs_vKJg**
Content-Type: application/json
Date: Thu, 13 Sep 2018 10:28:51 GMT
Content-Length

我的正则表达式为:regular expression extractor 但是我使用这个表达式得到多个值。如何仅获得一个授权令牌值? 请告诉我 。

2 个答案:

答案 0 :(得分:0)

您的问题可能是由于空白引起的,请更改您的正则表达式:

Authorization:(\s+)(.*)

然后使用模板$2$,它将忽略值之前的所有空白

答案 1 :(得分:0)

授权:“(。*?)”

然后使用模板$ 1 $