Home  >  Article  >  Backend Development  >  如何用preg_replace

如何用preg_replace

WBOY
WBOYOriginal
2016-06-13 10:05:35990browse

怎么用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);

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn