LeNgHoSt的小窝

I did it my way, ‘Cause it’s my life!

2008年07月28日

php中preg_match的用法

大家一看到preg_match肯定会头痛的。。。其实没什么,下面我就尽力给还不明白的兄弟们争取讲明白了,在这里我就不解释preg_match的说明了,朋友们可以通过php手册查看..先来个简单点的:

<?php
< ?
php
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";
?>

<<阅读全文>>

标签:, , ,