closing tags from opening tags using regex

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
PHPycho
Forum Contributor
Posts: 336
Joined: Fri Jan 06, 2006 12:37 pm

closing tags from opening tags using regex

Post by PHPycho »

Hello forums !!
I would like to know the closing tags for following strings using php

Code: Select all

$opening = '<div class="xxy">
<ul id="aab">
<li>';
$closing  = ? //should be </li></ul></div>
How to accomplish this using regular expression, any ideas ??
User avatar
markusn00b
Forum Contributor
Posts: 298
Joined: Sat Oct 20, 2007 2:16 pm
Location: York, England

Re: closing tags from opening tags using regex

Post by markusn00b »

Why use a regular expression? Can't you just close them like normal? :dubious:
Cut
Forum Commoner
Posts: 39
Joined: Sat Aug 23, 2008 8:01 pm

Re: closing tags from opening tags using regex

Post by Cut »

Use regular expressions to recognize <b>$1</b> and just escape <b> alone.
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Re: closing tags from opening tags using regex

Post by josh »

http://tidy.sourceforge.net/
opensource project for fixing HTML documents
Post Reply