小编Ama*_*nda的帖子

使用带有PHP的正则表达式替换文本

我有一个类似的字符串"apple|banana|peach|cherry".

如果匹配,我如何使用正则表达式搜索此列表并用特定值替换另一个字符串?

例如:

$input = 'There is an apple tree.';
Run Code Online (Sandbox Code Playgroud)

改为: "There is an <fruit>apple</fruit> tree."

谢谢,阿曼达

php regex

2
推荐指数
1
解决办法
422
查看次数

标签 统计

php ×1

regex ×1