Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.4k views
in Technique[技术] by (71.8m points)

regex to extract HTML attribute value

I have the following 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>

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

Any help please ?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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

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

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

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

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...