求一个正则表达式,去掉 <img>里alt的内容 求一个正则表达式,去掉 <img>里alt的内容,有以下几种格式:alt=""alt=ALT=""ALT=以上 正则表达式太菜,请给个具体点例子!3Q 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <?php $str =<<<EOD<img href="#" ALT="ceshi" >EOD;echo htmlspecialchars($str)."<br>";echo htmlspecialchars(preg_replace("/(.*)(alt=[\"\']?.*[\"\']?\s+)(.*)/i","\${1}\${3}",$str));//要确保ALT="ceshi"后有空格 否则无法匹配?> echo preg_replace("|(<img*.)(alt=[\"|']?.*['|\"])(.*/?>)|iu","$1$2",$str); $s = '<iMg name="" src="" ALT=111123 />';$r = '/(<img.+)(alt=\"?[^" ]*\"?)(.*)/i';$p = "\${1}alt=\"\" \$3";echo '<xmp>' . preg_replace($r,$p,$s); file_get_contents怎么时好时坏呢? php如何post xml到服务器 php 正则如何匹配数字 solr词根搜索问题 高薪诚聘:PHP程序员 fopen的問題 求一sql语句 thinkphp3.0 中的thinkeditor怎么用 authorize 接口出现错误,寻高手解决 微信公众平台 乱码 php循环中update数据,个别更新不全的问题 php字节流操作
$str =<<<EOD
<img href="#" ALT="ceshi" >
EOD;
echo htmlspecialchars($str)."<br>";
echo htmlspecialchars(preg_replace("/(.*)(alt=[\"\']?.*[\"\']?\s+)(.*)/i","\${1}\${3}",$str));//要确保ALT="ceshi"后有空格 否则无法匹配
?>
$r = '/(<img.+)(alt=\"?[^" ]*\"?)(.*)/i';
$p = "\${1}alt=\"\" \$3";echo '<xmp>' . preg_replace($r,$p,$s);