spikeon Posted March 21, 2008 Share Posted March 21, 2008 I am writing a code that will read a public database to gather information i have hit a snag where there can be more than one result for a specific type The Result could be: <tr><td class="TextResultsRowHeader">Set/Rarity:</td><td class="TextResultsRowValue">Morningtide Common</td></tr> Or: <tr><td class="TextResultsRowHeader">Set/Rarity:</td><td class="TextResultsRowValue">Morningtide Common, Ninth Edition Common, Onslaught Common</td></tr> Or many other variations, with up to 7 different sets and raritys. i want to seperate all of the sets from this list here is my regex: ereg(".*<tr><td class..TextResultsRowHeader.>Set/Rarity:</td><td class..TextResultsRowValue.>([a-zA-Z ]{1,30}) [a-zA-Z]{1,10}[,]{0,1}([a-zA-Z ]{0,30}) [a-zA-Z]{0,10}[,]{0,1}([a-zA-Z ]{0,30}) [a-zA-Z]{0,10}[,]{0,1}([a-zA-Z ]{0,30}) [a-zA-Z]{0,10}[,]{0,1}([a-zA-Z ]{0,30}) [a-zA-Z]{0,10}[,]{0,1}([a-zA-Z ]{0,30}) [a-zA-Z]{0,10}[,]{0,1}([a-zA-Z ]{0,30}) [a-zA-Z]{0,10}</td></tr>.*",$str, $matches); however, it dosen't seem to work. Help Please!!! Link to comment https://forums.phpfreaks.com/topic/97187-regex-not-working-noone-in-regex-forums-need-help-badly/ Share on other sites More sharing options...
laffin Posted March 21, 2008 Share Posted March 21, 2008 use the preg_match to grab everything than use explode to seperate the listing based on the comma, is simpler if(preg_match('<td class="TextResultsRowValue">(.*)</td>',$str,$matches)) $list=explode(',',$matches[1]) Link to comment https://forums.phpfreaks.com/topic/97187-regex-not-working-noone-in-regex-forums-need-help-badly/#findComment-497318 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.