首頁 >後端開發 >php教程 >如何用preg_replace

如何用preg_replace

WBOY
WBOY原創
2016-06-13 10:05:351048瀏覽

怎么用preg_replace
$content= "sdfggfhghjkjhkhljkljkljkadhkajdhkagfkhgkhgS?Hghjlfijsflkjaslfll
fgdfhsiodghoifgiosdg   p:/6117/civ/civ-issue/6117-mff.dgn   gjfdghfgdhd
p:/6117/civ/cov-issue/6117-mff.dgn   dfghdhfdgjgfjkgkhjkh........ "
要把$content中的所有绝对路径换成相对路径,如p:/6117/civ/civ-issue/6117-mff.dgn  
换为:6117-mff.dgn  
我想用preg_replace()做但没弄出来。

------解决方案--------------------
$content= "sdfggfhghjkjhkhljkljkljkadhkajdhkagfkhgkhgS?Hghjlfijsflkjaslfll
fgdfhsiodghoifgiosdg p:/6117/civ/civ-issue/6117-mff.dgn gjfdghfgdhd
p:/6117/civ/cov-issue/6117-mff.dgn dfghdhfdgjgfjkgkhjkh........ ";

echo preg_replace( "/[a-z]:\/\S+?\//iU ", " ", $content);

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn