Home > Backend Development > PHP Tutorial > 如何用preg_replace

如何用preg_replace

WBOY
Release: 2016-06-13 10:05:35
Original
1050 people have browsed it

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

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template