Example of a regular expression: obtain all superlinks on a webpage. Htmlheadtitle regular expression titleheadbodyahref. back to list abrformaction? Echo $ PHP_SELF ;? MethodpostURL: inputtypetextnameurlvalue? Echo $ url? Input
Regular expression
Back to list
If (isset ($ url )){
Echo "$ url has the following links:
";
$ 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];
}
}
}
?>
Http://www.bkjia.com/PHPjc/532485.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/532485.htmlTechArticlehtml headtitle regular expression/title/head body a href = "./" return list/abr form action = "? Echo $ PHP_SELF ;? "Method =" post "URL: input type =" text "name =" url "value = "? Echo $ url? "Input...