正则表达式提取 HTML 属性值 [英] regex to extract HTML attribute value

查看:34
本文介绍了正则表达式提取 HTML 属性值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下 HTML

<tr><td class="width35pct alignR"><span style="font-weight: bold;">TO :</span></td><td class="width40pct alignC"><input id="form:firstTON" name="form:firstTON" type="text" value="114" maxlength="17" tabindex="7" style="width:198px; margin: 5px 0 5px 0;" class="ui-inputfield ui-inputtext ui-widget ui-state-default ui-corner-all" /><script id="form:firstTON_s" type="text/javascript">//<![CDATA[PrimeFaces.cw('InputText','widget_form_firstTON',{id:'form:firstTON'});//]]><![CDATA[]]]]><![CDATA[></script></td><td class="alignl"><span style="font-weight: bold !important;" class="ar">number</span></td></tr>

我需要创建一个正则表达式来提取值114",这是value"属性的值.

And i need to create a regex that extract the value "114" which is the value of "value" attribute.

有什么帮助吗?

推荐答案

使用 JMeter,使用 Regular Expression Extractor 来完成这个任务.

Using JMeter, use Regular Expression Extractor to achieve this task.

Reference Name: mynum
Regular Expression: value="(.+?)"
Template: $1$
Match No.: 1

如果您指定使用Match No:,则规则如下:

If you specify using a Match No:, the rules are as follows:

0 = Random Match
1 = First Match 
2 = Second Match
etc....

然后就可以使用对应的变量来访问匹配了.${mynum_1}

And then you can use the corresponding variable to access the match. ${mynum_1}

这篇关于正则表达式提取 HTML 属性值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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