[img src=sorqin_2014523174838.jpg] 2013 asdfdfdghhhhhhh[img src=sorqin_2014523174838.jpg]sdgfdgdfghdhgfhjfjghjg
中的[img src=xxxx.jpg]改成<img src="./upload/xxxx.jpg" width="100px" height="100px">
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
不太熟悉PHP的正则,如果是在js里的话,可以这样
可以把上面的代码贴到浏览器的控制台里试一下
PHP中的话,使用PHP里相应的
replace方法应该就可以了$str = '[img src=sorqin_2014523174838.jpg] 2013 asdfdfdghhhhhhh[img src=sorqin_2014523174838.jpg]sdgfdgdfghdhgfhjfjghjg'; $hack = array('/\[/', '/\]/', '/(src=)(.+?\.jpg)/'); $replace = array('<', '>', '$1"./upload/$2" width="100px" height="100px"'); preg_replace($hack, $replace, $str);