regex - How to replace QUOTES like forums with php? -
i know should using preg_replace i'm not best regex. me code replacing [quote=user]quote here[/quote] to:
<p><b>user</b>quote here</p>
thanks lot in advance.
try this:
$str = '[quote=user]quote here[/quote]'; $regex = '/\[quote=(.+)\](.+?)\[\/quote\]/'; $replacement = '<p><b>$1</b>$2</p>'; $str = preg_replace($regex, $replacement, $str);
Comments
Post a Comment