Learn Regular Expressions
by
24 Apr 2003
This may look like pure nonsense: PHP Code:
$s = preg_replace("/\[mycode\](.*)\[\/mycode\]/siU", "<b>\\1</b>", $s);
A regexp (or regex) reference that I use is at http://www.english.uga.edu/humcomp/perl/regex2a.html (that's for Perl but the expressions themselves are almost exactly the same). Also see http://www.php.net/preg_replace , http://www.php.net/preg_match , and http://www.php.net/preg_match_all , as well as all the other preg_...() functions. |