首页 > 解决方案 > How can I extract Regular Expression in JMeter for the following?

问题描述

How can I extract only KK&JK from the following response in JMeter using Regular Expression Extractor?

<es2:ITEM>C2231597H88-KK&JK-M13122</es2:ITEM>

In the above response C2231597H88 is always 11 characters and M13122 is always 6 characters, but the number of characters for the value KK&JK in this example can change if that helps.

If I do <es2:ITEM>(.+?)< I get the whole thing C2231597H88-KK&JK-M13122, but I need to capture only KK&JK.

标签: javaregexjmeter

解决方案


尝试以下正则表达式模式:

<es2:ITEM>[^-]+-([^-]+)-[^-]+</es2:ITEM>

然后检查第一个捕获组,它应该包含您尝试定位的内容。

演示


推荐阅读