Jump to content

Regex


Minase

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/187150-regex/
Share on other sites

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

Link to comment
https://forums.phpfreaks.com/topic/187150-regex/#findComment-988282
Share on other sites

<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

Link to comment
https://forums.phpfreaks.com/topic/187150-regex/#findComment-988286
Share on other sites

'%(?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?

Link to comment
https://forums.phpfreaks.com/topic/187150-regex/#findComment-988305
Share on other sites

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...

Link to comment
https://forums.phpfreaks.com/topic/187150-regex/#findComment-988317
Share on other sites

<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

Link to comment
https://forums.phpfreaks.com/topic/187150-regex/#findComment-988372
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.