Reputation: 141
I want to get 2269 from below html response. I use
<td>XYZ Market Services \(Sydney\)</td>(?s).*name="addCompany" value="(.+?)"
Regular Expression with $1$ template and match number 1. but it returns 2271. Somebody please help me to create a regular expression to get the value 2269.
<tr>
<td>XYZ Market Services (Sydney)</td>
<td class="center">
<form action="/FormBuilder/pages/Folders/add.aspx?group=1424sfksdfsdgdsf243-3Q-w&ajax=true" method="post">
<input name="addCompany" value="2269" type="hidden" /><input class="XYZLookAlike" type="button" onclick="fnload(this)" value="Add" />
</form>
</td>
</tr>
<tr>
<td>XYZ Market Services (Melbourne)</td>
<td class="center">
<form action="/FormBuilder/pages/Folders/add.aspx?group=1424sfksdfsdgdsf243-3Q-w&ajax=true" method="post">
<input name="addCompany" value="2271" type="hidden" /><input class="XYZLookAlike" type="button" onclick="fnload(this)" value="Add" />
</form>
</td>
</tr>
Thank you...
Upvotes: 0
Views: 731
Reputation: 34536
To parse HTML, the best extractor is CSS/JQuery extractor in terms of Maitainability/easyness/performance is:
See this regarding performances of extractors:
Upvotes: 1
Reputation: 168092
Don't use regular expressions to parse HTML, there are way better options.
For example you can use XPath Extractor which allows executing arbitrary XPath queries against the response, here is an example of extracting value
attribute for addCompany
input where column text is XYZ Market Services (Sydney)
//td[text()='XYZ Market Services (Sydney)']/following-sibling::*/form/input[@name='addCompany']/@value
Demo:
More information: Using the XPath Extractor in JMeter
Upvotes: 1