-2

Possible Duplicate:
How to convert HTML to BBCode

how can i parse

<tag attr="z">
<tag attr="y">
<tag attr="x"></tag>
</tag>
</tag>

to

<tag attr="z">
[tag=y]
<tag attr="x"></tag>
[/tag]
</tag>

Without using extensions ...

Community
  • 1
  • 1
net-User
  • 25
  • 6
  • You're trying to transform HTML back into BB tags. The typical dumb SO comments ala "you can't parse html with regex" is relevant here (albeit wrong). It's just awfully difficult. Matching the right closing `` is no small feat. So use a DOM frontend or the mentioned XSLT approach. – mario Aug 11 '12 at 12:43
  • I cant use extensions .. =\ and i cant use frontend .. – net-User Aug 11 '12 at 12:49
  • DOMDocument is the built-in traversal frontend to the libxml2 parser. The XSLT functions are often not, but a xslt processor is often available through the commandline. If you don't like either simple option, you're either in for a lot of workaround coding, or plain [googling](http://www.google.de/search?client=opera&rls=de&q=convert+html+back+to+bbcode). – mario Aug 11 '12 at 12:56
  • I updated my question and explained it better .. – net-User Aug 11 '12 at 14:24

1 Answers1

-1

PHP can handle BBCode itself. See Here

Madara's Ghost
  • 172,118
  • 50
  • 264
  • 308