正则表达式提取HTML属性值

时间:2015-04-02 04:15:30

标签: html regex jmeter

我有以下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>

我需要创建一个提取值的正则表达式&#34; 114&#34;这是&#34;价值&#34;的价值。属性。

请帮忙吗?

1 个答案:

答案 0 :(得分:1)

使用JMeter,使用Regular Expression Extractor来完成此任务。

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

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

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

然后您可以使用相应的变量来访问匹配项。 ${mynum_1}