TestingWithArif TestingWithArif - 4 days ago 8
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<


returns

value="53">1ABC Class<


In the example given, the only return values I want are
53
,
52
and
69
.

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

Answer

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.

Comments