Discuz教程网

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

[复制链接]
authicon 09927306 发表于 2011-1-6 12:36:57 | 显示全部楼层 |阅读模式
  1. <html>
  2. <head><title>正则表达式</title></head>
  3. <body>
  4. <a href="./">返回列表</a><br>
  5. <form action="<?echo $PHP_SELF;?>" method="post">
  6. URL: <input type="text" name="url" value="<?echo $url?>"><input type="submit" value="获取所有裢接">
  7. </form>
  8. <?
  9. if(isset($url)){
  10. echo "$url 有下列裢接:<br>";
  11. $fcontents = file($url);
  12. while(list(,$line)=each($fcontents)){
  13. while(eregi(\'(href[[:space:]]*=[[:space:]]*"?[[:alnum:]:@/._-]+"?)(.*)\',$line,$regs)){
  14. $regs[1] = eregi_replace(\'(href[[:space:]]*=[[:space:]]*"?)([[:alnum:]:@/._-]+)("?)\',"\\\\2",$regs[1]);
  15. echo "    $regs[1]<br>";
  16. $line = $regs[2];
  17. }
  18. }
  19. }
  20. ?>
  21. </body>
  22. </html>
复制代码






上一篇:PHP汉字验证码的实现
下一篇:【Discuz X】单页制作教程(附各种形式模板)
authicon 月之海洋 发表于 2011-6-18 09:59:52 | 显示全部楼层
继续来索要
authicon rin421 发表于 2011-6-24 00:00:12 | 显示全部楼层
这个不错呀
authicon 陶衣小可 发表于 2011-6-25 22:59:47 | 显示全部楼层
好东东下下来看看
authicon yuki佳 发表于 2011-8-10 02:00:05 | 显示全部楼层
哈哈,支持了
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

1314学习网 ( 浙ICP备10214163号 )

GMT+8, 2025-5-2 14:22

Powered by Discuz! X3.4

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表