使用 preg_replace 将文本添加到行中?

Using preg_replace to add text into line?

这是我正在使用的示例行:

<br/>
About Company Name<br/>
<p>This is just some random text About nothing.</p>
<br/>

基本上我想操纵任何以 About 开头并以 <br/> 结尾的行。

我只想像这样加粗:<b>About Company Name</b><br/>

我可以找到这样的文字:

^About.*<br/>

但我不知道如何添加粗体符号。任何帮助将不胜感激。

像这样向您的正则表达式添加一个捕获组:

^(About.*)<br\/>$

然后像这样使用正则表达式:

$s = preg_replace('/^(About.*)<br\/>$/m', '<b></b><br/>', $s);

Regex101 Tested