Problem with RegEx for BBCode
| From: | Asmann, Roland | Date: | Sat, 27 Nov 2010 13:57:13 +0000 |
| Subject: | Problem with RegEx for BBCode | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-309709@lists.php.net to get a copy of this message | ||
Hi all,
I am playing around with PHP and BBCodes and have found some regex's
that should transform my BBCode into correct HTML when rendering.
However, I have found that if the BBCode is not correct (eg missing
closing tag), the regex completely eats my input and my page is empty!
The regex I'm using is:
/\[i\]((\s|.)+?)\[\/i\]/
And with an input like:
This is [i]italic.
I get nothing back.
What I would like is that when no closing tag is found, the opening tag
should just be shown as-is. Anybody have any idea how I can do this?
Thanks!
--
Roland Asmann
Senior Software Engineer
adesso Austria GmbH
Floridotower 26. Stock T +43 1 2198790-27
Floridsdorfer Hauptstr. 1 F +43 1 2198790-927
A-1210 Wien M +43 664 88657566
E roland.asmann@adesso.at
W www.adesso.at
-------------------------------------------------------------
>>> business. people. technology. <<<
-------------------------------------------------------------