Limiting regex match
Posted
by
DMIL
on Stack Overflow
See other posts from Stack Overflow
or by DMIL
Published on 2012-03-27T22:43:40Z
Indexed on
2012/03/27
23:29 UTC
Read the original article
Hit count: 410
Say I have this HTML fragment
<td width="25%" style="text-align:right;" >
<span style="font-family: Arial; font-size: 12px;">
<strong>Regular price:</strong></span>
</td>
<td width="25%" style="text-align:center;" >
<span style="font-family: Arial; font-size: 12px;>
<strong>11,100.00 USD</strong></span>
</td>
<td width="25%" style="text-align:right;" >
<span style="font-family: Arial; font-size: 12px;">
<strong>Web price:</strong></span>
</td>
<td width="25%" style="text-align:center;" >
<span style="font-family: Arial; font-size: 12px;>
<strong>9,100.00 USD</strong></span>
</td>
How would I get the first amount (11,100.00) using regex? I tried
/Regular price.+(\d[^\s]+)\sUSD/is
but it's not working, it's returning '00'. Obviously I'm a newbie at regex and I'm hoping to get by without picking up a book.
And I HAVE to use regex to parse this HTML because that particular site was designed by someone who doesn't know about classes or IDs.
© Stack Overflow or respective owner