TestingWithArif TestingWithArif - 1 year ago 89
HTML Question

How to get first only first 2 digits using Regular expression

I am using JMeter and trying to write a Regular expression (regex) that can return the two digit class ID from some HTML option elements.

<option value="53">1ABC Class</option>
<option value="52">2XYZ Class</option>
<option value="69" selected="selected">001 Class</option>

using following regex..

value="..">1ABC Class<


value="53">1ABC Class<

In the example given, the only return values I want are

I am looking for a regex that will work with all of above given options.

Answer Source

Try this:

value="(\d+)".*?>1ABC Class<

This will give the result in the brackets as the needed value only, plus it would match any tag.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download