This will replace all versions (open and close) of bold, italicize and underline tags with brackets using preg_replace.
$text = preg_replace("/\[(\/)?([biu])\]/","<\\1\\2>",$text) ; <definition> - find [ = "\[" - match IF slash exists = "(\/)?" - match one of the following = "([biu])" - find ] = "\]" - matches get put into 'memory' (\\1 \\2) even if not found (ie. slash didn't exist). - replace with "< 'first match' 'second match' >" - NOTE : in PCRE regexs, brackets and forward-slashes are special characters and must be escaped (preceded with a back-slash) when looking for them as regular characters. </definition> Even if you do not know PCRE yet, don't hamstring yourself looking for a solution that is too complicated and time-consuming. EREG does not work very well on this type of problem. Buck up, learn PCRE and use this type of solution (if you find something that works for you, use it...by no means does the code above cover every tag you 'may' want to use). Builder.com has a pretty good regular expression checker for PERL-style regexs that make PCRE pretty easy. http://builder.com -> Go To: Web Scripting (left menu) -> Cool Tools (right menu) -> Regular Expression Inspector (2/3 way down page) .mike ======================================= Michael Geier CDM Sports, Inc. Systems Administration email: [EMAIL PROTECTED] phone: 314.991.1511 x 6505 ----------------------------------------------- This email sent using CDM Sports Webmail v3.1 [ http://webmail.cdmsports.com ] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php