<?php
// 从 URL 中取得主机名
preg_match("/^(http:////)?([^//]+)/i",
"http://www.php.net/index.html", $matches);
$host = $matches[2];
// 从主机名中取得后面两段
preg_match("/[^/.//]+/.[^/.//]+$/", $host, $matches);
echo "domain name is: {$matches[0]}/n";
//验证邮件地址格式
if(!eregi("^[_a-z0-9-]+(/.[_a-z0-9-]+)*@[a-z0-9-]+(/.[a-z0-9-]+)*(/.[a-z]{2,3})$",
$_GET["txtEmail"])) {
$message = "This e-mail address is not valid";
} else {
$valid = "true";
$message = "";
}
?> $aa = "是我<img src='bcc.jpg'>是它 <img src=/"xxx.jpg/" > ";
preg_match_all( "//<img/s*src=[/"|/']/w*/./w*[/"|/']/s*>/" , $aa ,$array );
print_r( $array ); //找出 <img> 的字符串,不完善,自改
编辑器替换
<?php
//$v = "http://www.izhongshan.cn/members/summary/media/Supermodels.wmv";
$v["wmv"]="[wmv]http://www.izhongshan.cn/members/summary/media/Supermodels.wmv[/wmv]";
$v["rm"] ="[rm]http://tv.mofile.com/cn/xplayer.swf?v=PL5KXRCO&p=http://cache.mofile.com/tv/static/picture/u14/Disk1/ctc/2007/4/26/PL/5K/PL5KXRCO.jpg&autoplay=0[/rm]";
$v["flash"]="[flash=400,300]http://www.21cn.com[/flash]";
$reg["wmv"] = "//[wmv/]http/:////(/w|/.|//)+/.wmv/[//wmv/]/";
$reg["rm"] = "//[rm/]http/:////(/w|/.|//|/&|/?|/=|/:|//)+/[//rm/]/";
$reg["flash"] = "//[flash/=/d*/,/d*/]http/:////(/w|/.|//)+/[//flash/]/";
echo"<br><br>wmv= ". preg_replace($reg["wmv"],"点击进入播放wmv",$v["wmv"]);
echo"<br><br>rm= ". preg_replace($reg["rm"],"点击进入播放rm",$v["rm"]);
echo"<br><br>flash= ". preg_replace($reg["flash"],"点击进入播放flash",$v["flash"]);
//博客专用......
function ContentCut($code,$len){
if($len){
$code = preg_replace("/<br>/is","/t",$code);
$code = preg_replace("//<(.+?)/>/is",'',$code);
$code = preg_replace("//[(.+?)/]/is",'',$code);
$code = substrs($code,$len);
$code = str_replace("/t","<br>",$code);
}
return $code;
}
?>