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

查看:374
本文介绍了正则表达式提取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",这是值"属性的值.

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

请帮忙吗?

推荐答案

使用JMeter,使用 正则表达式提取器 来完成此任务.

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天全站免登陆