If you are new to domains and looking to buy, sell and learn about domains then you have come to the right place. DNForum is the largest domain name community on the internet and continues to grow every day. There are over 105,000 domainers on DNForum doing everything from buying domains, selling domains, learning about domains and discussing domains. Take a minute and Register.
Register Today on DNForum IT'S FREE!Hey all,
I'm having a few troubles with a regular expression in PHP. Basically, the regular expression I'm using is:
This would change, for example:Code:preg_replace("@/{$cat}/{$cDesc}/\" title=\"(.+)\">(.+)</a></li>@","@/{$cat}/{$cDesc}/\" title=\"$1\">$2</a>". $output ."</li>@", $navBar);
into:Code:<li><a href="http://www.tauonline.org/TrialV7/Cat.php/14/ImperialGuard/" title="Fall in, soldier, and we will teach you how to fight for the Emperor!">Imperial Guard</a></li> <li><a href="http://www.tauonline.org/TrialV7/Cat.php/15/ChaosSpaceMarines/" title="This section is for the ways of the Forces of Chaos.">Chaos Space Marines</a></li> <li><a href="http://www.tauonline.org/TrialV7/Cat.php/16/DaemonHunters/" title="Discover how to better protect Humanity from the Daemonic Hordes!">Daemon Hunters</a></li> <li><a href="http://www.tauonline.org/TrialV7/Cat.php/17/WitchHunters/" title="Discover how to seek out the Heretic, Mutant and Traitor.">Witch Hunters</a></li> <li><a href="http://www.tauonline.org/TrialV7/Cat.php/18/Tyranids/" title="The Tyranids hunt their prey here.">Tyranids</a></li>
As you can see, the "@" signs I'm using as delimiters in the reg. exp are being outputted - any ideas why, and how can I stop this?Code:<li><a href="http://www.tauonline.org/TrialV7/Cat.php/14/ImperialGuard/" title="Fall in, soldier, and we will teach you how to fight for the Emperor!">Imperial Guard</a></li> <li><a href="http://www.tauonline.org/TrialV7/Cat.php/15/ChaosSpaceMarines/" title="This section is for the ways of the Forces of Chaos.">Chaos Space Marines</a></li> <li><a href="http://www.tauonline.org/TrialV7/Cat.php@/16/DaemonHunters/" title="Discover how to better protect Humanity from the Daemonic Hordes!">Daemon Hunters</a><ul> <li title="This allows you to see only articles (in this categeory) of the selected type" class="SmallText">Filter Articles By:</li> <li class="SmallText"><a href="http://www.tauonline.org/TrialV7/Cat.php/16/DaemonHunters/House Rule" title="View only Daemon Hunters articles only of the type 'House Rule'">House Rule</a></li> <li class="SmallText"><a href="http://www.tauonline.org/TrialV7/Cat.php/16/DaemonHunters/Tactics" title="View only Daemon Hunters articles only of the type 'Tactics'">Tactics</a></li> </ul></li>@ <li><a href="http://www.tauonline.org/TrialV7/Cat.php/17/WitchHunters/" title="Discover how to seek out the Heretic, Mutant and Traitor.">Witch Hunters</a></li> <li><a href="http://www.tauonline.org/TrialV7/Cat.php/18/Tyranids/" title="The Tyranids hunt their prey here.">Tyranids</a></li>
Thanks,
Tristan
you don't need to add the delimiter into the replace part this regular expression should work for you:
Code:preg_replace("@/{$cat}/{$cDesc}/\" title=\"(.+)\">(.+)</a></li>@","/{$cat}/{$cDesc}/\" title=\"$1\">$2</a>". $output ."</li>", $navBar);
Canadian Registrar ~~ Ready.ca
Bookmarks