Home > php教程 > php手册 > 正则表达式例子:获得某个网页上的所有超裢接

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

WBOY
Release: 2016-06-21 09:13:38
Original
1123 people have browsed it

网页|正则


正则表达式

返回列表


URL:


if(isset($url)){
    echo "$url 有下列裢接:
";
    $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]
";
            $line = $regs[2];
        }
    }
}
?>





Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template