Minase Posted January 4, 2010 Share Posted January 4, 2010 now im really stuck ... i work with regex for some time,but not for PHP can someone help me with this one (?<full><tr><td>(?<rank>.*?)</td><td><img src="img/race(?<race>.*?)small.gif.*?</td><td>(.*?)?p=(?<pid>.*?)".*?title="(?<name>.*?)".*?</td><td>.*?\?i=(?<aid>.*?)" >(?<aname>.*?)</a></td>.*?>(?<level>.*?)</td>.*?>(?<capture>.*?)</td>.*?>(?<victims>.*?)</td>.*?>(?<victorys>.*?)</td>.*?>(?<defeats>.*?)</td>.*?>(?<goldtook>.*?)</td></tr>){0,100} i think the code is explaining what i want to achieve thank you Quote Link to comment https://forums.phpfreaks.com/topic/187150-regex/ Share on other sites More sharing options...
JAY6390 Posted January 4, 2010 Share Posted January 4, 2010 Is it that you just need the delimiters either side of the regex put ~ on either side and see if it works then Quote Link to comment https://forums.phpfreaks.com/topic/187150-regex/#findComment-988277 Share on other sites More sharing options...
Minase Posted January 4, 2010 Author Share Posted January 4, 2010 look what i have tried $regex = "~(?<full><tr><td>(?<rank>.*?)</td><td><img src=\"img/race(?<race>.*?)small.gif.*?</td><td>(.*?)?p=(?<pid>.*?)\".*?title=\"(?<name>.*?)\".*?</td><td>.*?\?i=(?<aid>.*?)\" >(?<aname>.*?)</a></td>.*?>(?<level>.*?)</td>.*?>(?<capture>.*?)</td>.*?>(?<victims>.*?)</td>.*?>(?<victorys>.*?)</td>.*?>(?<defeats>.*?)</td>.*?>(?<goldtook>.*?)</td></tr>){0,100}~"; with no luck... but is this regex good for php? didnt work too much with regex in php Quote Link to comment https://forums.phpfreaks.com/topic/187150-regex/#findComment-988282 Share on other sites More sharing options...
JAY6390 Posted January 4, 2010 Share Posted January 4, 2010 Can you post the exact code you're trying to match Quote Link to comment https://forums.phpfreaks.com/topic/187150-regex/#findComment-988284 Share on other sites More sharing options...
Minase Posted January 4, 2010 Author Share Posted January 4, 2010 <tr><td>1</td><td><img src="img/race1small.gif" alt="waslp" ></td><td><a href="?p=35357" title="Minase">Minase</a></td><td><a href="?i=115" >Black</a></td><td align="right">331</td><td align="right">355.938.160</td><td align="right">9</td><td align="right">10.070</td><td align="right">1.835</td><td align="right">1.682.527</td></tr> i have thousands of matches,i want to put every match in array thx Quote Link to comment https://forums.phpfreaks.com/topic/187150-regex/#findComment-988286 Share on other sites More sharing options...
JAY6390 Posted January 4, 2010 Share Posted January 4, 2010 oh for naming the groups, it should be ?P<name_here> not ?<name_here> Try changing that Quote Link to comment https://forums.phpfreaks.com/topic/187150-regex/#findComment-988287 Share on other sites More sharing options...
Minase Posted January 4, 2010 Author Share Posted January 4, 2010 nope doesnt work.. Quote Link to comment https://forums.phpfreaks.com/topic/187150-regex/#findComment-988293 Share on other sites More sharing options...
JAY6390 Posted January 4, 2010 Share Posted January 4, 2010 '%(?P<full><tr><td>(?<rank>.*?)</td><td><img src=\"img/race(?<race>.*?)small.gif.*?</td><td>(.*?)?p=(?<pid>.*?)\".*?title=\"(?<name>.*?)\".*?</td><td>.*?\?i=(?<aid>.*?)\" >(?<aname>.*?)</a></td>.*?>(?<level>.*?)</td>.*?>(?<capture>.*?)</td>.*?>(?<victims>.*?)</td>.*?>(?<victorys>.*?)</td>.*?>(?<defeats>.*?)</td>.*?>(?<goldtook>.*?)</td></tr>)%' Try that. Also, what is your php code you are using? are you using preg_match_all? Quote Link to comment https://forums.phpfreaks.com/topic/187150-regex/#findComment-988305 Share on other sites More sharing options...
Minase Posted January 4, 2010 Author Share Posted January 4, 2010 yes but kill me... $regex = '%(?P<full><tr><td>(?P<rank>.*?)</td><td><img src=\"img/race(?P<race>.*?)small.gif.*?</td><td>(.*?)?p=(?P<pid>.*?)\".*?title=\"(?P<name>.*?)\".*?</td><td>.*?\?i=(?P<aid>.*?)\" >(?P<aname>.*?)</a></td>.*?>(?P<level>.*?)</td>.*?>(?P<capture>.*?)</td>.*?>(?P<victims>.*?)</td>.*?>(?P<victorys>.*?)</td>.*?>(?P<defeats>.*?)</td>.*?>(?P<goldtook>.*?)</td></tr>)%'; preg_match_all($regex,$string,$matches, PREG_SET_ORDER); print_r($matches); this returns nothing... Quote Link to comment https://forums.phpfreaks.com/topic/187150-regex/#findComment-988317 Share on other sites More sharing options...
salathe Posted January 4, 2010 Share Posted January 4, 2010 What is the $string that you're using? Quote Link to comment https://forums.phpfreaks.com/topic/187150-regex/#findComment-988344 Share on other sites More sharing options...
Minase Posted January 4, 2010 Author Share Posted January 4, 2010 it's the text ... Quote Link to comment https://forums.phpfreaks.com/topic/187150-regex/#findComment-988346 Share on other sites More sharing options...
salathe Posted January 4, 2010 Share Posted January 4, 2010 Yes, but what is it? Quote Link to comment https://forums.phpfreaks.com/topic/187150-regex/#findComment-988361 Share on other sites More sharing options...
Minase Posted January 4, 2010 Author Share Posted January 4, 2010 <tr><td>1</td><td><img src="img/race1small.gif" alt="waslp" ></td><td><a href="?p=35357" title="Minase">Minase</a></td><td><a href="?i=115" >Black</a></td><td align="right">331</td><td align="right">355.938.160</td><td align="right">9</td><td align="right">10.070</td><td align="right">1.835</td><td align="right">1.682.527</td></tr> that type of strings i have thousands of matches,i want to put every match in array thanks Quote Link to comment https://forums.phpfreaks.com/topic/187150-regex/#findComment-988372 Share on other sites More sharing options...
Minase Posted January 5, 2010 Author Share Posted January 5, 2010 stupid me i was using htmlentities witch replaced the tags to text was normal for regex to not find it. thank you all for help Quote Link to comment https://forums.phpfreaks.com/topic/187150-regex/#findComment-988744 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.