如何用preg_replace
程序员文章站
2022-05-05 15:03:21
...
怎么用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);
$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);
相关文章
相关视频
上一篇: MySql模糊查询总结
下一篇: 浅谈MySQL索引背后的数据结构及算法