Home > Backend Development > PHP Tutorial > 【】 php 正则 替换音乐地址和图片地址

【】 php 正则 替换音乐地址和图片地址

WBOY
Release: 2016-06-13 13:27:22
Original
872 people have browsed it

【在线等】 php 正则 替换音乐地址和图片地址
请教各位大侠 php 正则 替换音乐地址和图片地址

比如 音乐地址 http://sdsds.com/sdds/def/das.mp3
  http://sdse22s.com/s22dds/d2ef/da333s.wma
  http://sdsds.c55om/sdd44s/de33f/d2222s.wav

比如 图片地址 http://gggfefgg.com/da3s/ddderv.jpg
  http://saeggg.com/d3as/dddswe.gif
  http://ggbgg.com/da2s/dd86.png

现在从数据库里读出一段内容,怎么把这些图片和音乐匹配出来替换成其他的呢

------解决方案--------------------

PHP code
[User:root Time:09:37:50 Path:/home/liangdong/php]$ php preg.php 
这是图片<img  src="http://gggfefgg.com/da3s/ddderv.jpg" alt=" 【】  php 正则 替换音乐地址和图片地址 " >[User:root Time:09:37:51 Path:/home/liangdong/php]$ cat preg.php 
<?php $str = <<<EOF
这是图片http://gggfefgg.com/da3s/ddderv.jpg
EOF;
$str = preg_replace('/这是图片(http:\/\/.*\.jpg)/iUs', '这是图片<img  src="\1" / alt=" 【】  php 正则 替换音乐地址和图片地址 " >', $str);
print_r($str);
?> <div class="clear">
                 
              
              
        
            </div>
Copy after login
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