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.
例如,我有一个字符串:“This is a !thing”
我怎么能这样 - “这是一个!<b>thing</b>”
!<b>thing</b>
任何帮助,将不胜感激。
多谢你们。
preg_replace('/!(\w+)/', '!<b>$1</b>', $string);
在替换字符串$n中,替换为正则表达式中任何匹配n的捕获组。
$n
n