2015-04-02 120 views
1

我有以下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」屬性的值。

請幫忙嗎?

+3

你在用什麼**語言? – hwnd 2015-04-02 04:15:57

+0

上午使用Jmeter,我需要從響應驅動這個值 – User 2015-04-02 04:20:31

回答

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}

+1

非常感謝你hwnd :) – User 2015-04-02 04:29:16