使用php替换正则表达式与正则表达式

我想使用相同的哈希标签替换字符串中的哈希标签,但在添加链接之后

例:

$text = "any word here related to #English must #be replaced."

我想替换每个主题标签

#English ---> <a href="bla bla">#English</a>
#be ---> <a href="bla bla">#be</a>

所以outpu应该是这样的:

$text = "any word here related to <a href="bla bla">#English</a> must <a href="bla bla">#be</a> replaced."

谢谢

$input_lines="any word here related to #English must #be replaced.";
preg_replace("/(#\w+)/","<a href='bla bla'>$1</a>",$input_lines);

DEMO

OUTPUT:

any word here related to <a href='bla bla'>#English</a> must <a href='bla bla'>#be</a> replaced.

相关文章

统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
前言 之前做了微信登录,所以总结一下微信授权登录并获取用户...
FastAdmin是我第一个接触的后台管理系统框架。FastAdmin是一...
之前公司需要一个内部的通讯软件,就叫我做一个。通讯软件嘛...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...