Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我知道我可能应该使用 preg_replace 但我不是最好的正则表达式。有人可以帮助我将 [QUOTE=user]quote here[/QUOTE] 替换为:
<p><b>user</b>quote here</p>
提前非常感谢。
尝试这个:
$str = '[QUOTE=user]quote here[/QUOTE]'; $regex = '/\[QUOTE=(.+)\](.+?)\[\/QUOTE\]/'; $replacement = '<p><b>$1</b>$2</p>'; $str = preg_replace($regex, $replacement, $str);