我有一个类似的字符串"apple|banana|peach|cherry".
"apple|banana|peach|cherry"
如果匹配,我如何使用正则表达式搜索此列表并用特定值替换另一个字符串?
例如:
$input = 'There is an apple tree.';
改为: "There is an <fruit>apple</fruit> tree."
"There is an <fruit>apple</fruit> tree."
谢谢,阿曼达
php regex
php ×1
regex ×1