JMeter-选择正则表达式的一部分 [英] JMeter - Selecting Part of a Regular Expression

查看:264
本文介绍了JMeter-选择正则表达式的一部分的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个JMeter正则表达式提取器,该提取器搜索以下正则表达式:

I have a JMeter Regular Expression Extractor which searches for the following regular expression:

myId=[0-9]{10}

这将从我的网站表单中检索10位数字的ID号.然后,我为ID号设置myId的引用名称".我的模板值为$ 0 $,我的匹配号设置为空白.

This retrieves the 10 digit numeric id number from my websites form. I then set a "Reference Name" of myId for the id number. My template value is $0$ and my match No. is set to blank.

然后在我的HTTP请求中,传递参数值:

In my HTTP Request, I then pass a parameter value of:

${myId}

当我运行JMeter测试时,它将以以下形式插入文本:

When I run my JMeter test, it inserts text in the form of:

myId=myId=1234567890

如何摆脱重复的myId =?

How do I get rid of the duplicate myId=?

推荐答案

不确定JMeter的RegEx实现,但通常情况下

Not sure about JMeter's implementation of RegEx but normally

myId=[0-9]{10}

将匹配所有内容,包括myId=.您需要使用()定义要提取的捕获组,然后将引用捕获组数组并获取所需的项.例如

would match everything, including myId=. What you need is to define capture groups that you want extracted using () and then you will reference the capture group array and get the item you want. E.g.

myId=([0-9]{10})

第0组仍然是完整的东西,但第1组将只是由()分隔的数字部分,即没有myId=.希望这会有所帮助.

group 0 would still be the whole thing but group 1 would be just the numeric portion as delimited by (), i.e. without myId=. Hope this helps.

这篇关于JMeter-选择正则表达式的一部分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆