-2
在PHP中我儘量做到改變一個字符串:正則表達式的preg_replace:單獨的路徑和文件名
<img class="alignnone size-medium wp-image-18" src="http://localhost/wp-content/uploads/2015/02/300x149-jquerymobile.jpg" alt="jquerymobile" width="300" height="149">
這樣:
<img class="alignnone size-medium wp-image-18" src="" data-path="http://localhost/wp-content/uploads/2015/02/" data-img="300x149-jquerymobile.jpg" alt="jquerymobile" width="300" height="149">
我想不想用
preg_replace('/src="(what-is-a-path-regex)(.*)"/', 'src="" data-path="$1" data-img="$2"', '<img class="alignnone size-medium wp-image-18" src="http://localhost/wp-content/uploads/2015/02/300x149-jquerymobile.jpg" alt="jquerymobile" width="300" height="149">')
什麼正則表達式是要取代「wat-is-a-path-regex」?