Usage & quot; width & quot; 100px & quot; height & quot; 100px & quot; & amp; gt;
[img src=sorqin_2014523174838.jpg] 2013 asdfdfdghhhhhhh[img src=sorqin_2014523174838.jpg]sdgfdgdfghdhgfhjfjghjg
In[img src=xxxx.jpg]Change
Reply content:
[img src=sorqin_2014523174838.jpg] 2013 asdfdfdghhhhhhh[img src=sorqin_2014523174838.jpg]sdgfdgdfghdhgfhjfjghjg
In[img src=xxxx.jpg]Change
$str = '[img src=sorqin_2014523174838.jpg] 2013 asdfdfdghhhhhhh[img src=sorqin_2014523174838.jpg]sdgfdgdfghdhgfhjfjghjg';$str = preg_replace('/\[img\s+src=(.*?)\]/is', '', $str);echo $str;
I am not familiar with PHP regular expressions. If it is in js, you can do this.
var str = '[img src=sorqin_2014523174838.jpg] 2013 asdfdfdghhhhhhh[img src=sorqin_2014523174838.jpg]sdgfdgdfghdhgfhjfjghjg';str.replace(/\[/g, '<').replace(/\]/g, '>').replace(/(src=)(.+?\.jpg)/g, '$1"./upload/$2" width="100px" height="100px"');
You can paste the above Code to the browser console and try it out.
In PHP, use the correspondingreplaceThe method should be enough.
$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);