Link to home
Start Free TrialLog in
Avatar of gamebits
gamebitsFlag for Canada

asked on

preg_match_all regex lookbehind pattern

This question is related to question https://www.experts-exchange.com/questions/26620121/Using-preg-match-all-how-can-you-capture-a-string-conditional-to-another-string-being-present-in-the-text-to-parse.html?cid=239&anchorAnswerId=34151863#a34151863

As I explained before I'm parsing the html of an auction page I got help from an expert as to how to do a lookahead regex so I could grab the title of the auction only if the item is sold.

Now I'm running in the same situation because I need to grab the auction end date but again only if the item is sold, my problem is the date come after the sold flag in the source code.

an example of the data to parse

<td class=\"bids bin1\">0 Bids</td><td class=\"prc binsold g-b\">$19.99</td><td class=\"tme  rt\"><b class=\"hidlb\">End Date:</b><span>Nov-15 19:00</span></td>

<td class=\"bids\"><div class=\"bin1\">7 Bids</div><span class=\"sold\">Sold</span></td><td class=\"prc bidsold g-b\">$55.32</td><td class=\"tme  rt\"><b class=\"hidlb\">End Date:</b><span>Nov-15 19:00</span></td>

As can be seen in the example an unsold item does not have the "<span class=\"sold\">Sold</span>" string

preg_match_all is a must because there is multiple lines to be parse.


ASKER CERTIFIED SOLUTION
Avatar of hernst42
hernst42
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of gamebits

ASKER

Right on the money, awesome, you the man.

Thanks