标签: regex
$string = "I have the string like "this is the [image1] of the home. this is the [image2] of the home"
我希望[image1]替换为"uploads/1.jpg",[image2]为"uploads/2.jpg"。
[image1]
"uploads/1.jpg"
[image2]
"uploads/2.jpg"
请帮帮我
答案 0 :(得分:1)
正则表达式:
\[image(\d+)\]
替换字符串:
uploads/\1.jpg