当前位置: 首页 > 图文教程 > 网络编程 > PHP > 正则表达式例子:获得某个网页上的所有超裢接

PHP
php简单的分页程序
加强版phplib的DB类
PHP 数字左侧自动补0
mysql+php分页类(已测)
php读取30天之内的根据算法排序的代码
在php MYSQL中插入当前时间
用php获取远程图片并把它保存到本地的代码
生成php程序的php代码
在PHP中读取和写入WORD文档的代码
用来给图片加水印的PHP类
php md5下16位和32位的实现代码
php出现Cannot modify header information问题的解决方法大全
PHP提取中文首字母
php Ajax乱码
php时间不正确的解决方法
php的access操作类
如何在PHP程序中防止盗链
PHP中的extract的作用分析
PHP中用header图片地址 简单隐藏图片源地址
PHP防注入安全代码

PHP 中的 正则表达式例子:获得某个网页上的所有超裢接


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-08-14   浏览: 245 ::
收藏到网摘: n/a

<html>
<head><title>正则表达式</title></head>
<body>
<ahref="./">返回列表</a><br>
<formaction="<?echo$PHP_SELF;?>"method="post">
URL:<inputtype="text"name="url"value="<?echo$url?>"><inputtype="submit"value="获取所有裢接">
</form>
<?
if(isset($url)){
echo"$url有下列裢接:<br>";
$fcontents=file($url);
while(list(,$line)=each($fcontents)){
while(eregi('(href[[:space:]]*=[[:space:]]*"?[[:alnum:]:@/._-]+"?)(.*)',$line,$regs)){
$regs[1]=eregi_replace('(href[[:space:]]*=[[:space:]]*"?)([[:alnum:]:@/._-]+)("?)',"\\2",$regs[1]);
echo"$regs[1]<br>";
$line=$regs[2];
}
}
}
?>
</body>
</html>