Home > Backend Development > PHP Tutorial > 关于正则,求高手帮助

关于正则,求高手帮助

WBOY
Release: 2016-06-23 14:19:51
Original
856 people have browsed it

如例:
http://bbs.csdn.net/topics/new?forum_id=PHP
http://www.bdyy.cc/detail/?20236.html
http://www.qq.com/html/?20236.html?id=88888

preg_match('/(http:\/\/)(.*)(\/)/',$rrr,$matches);

如何分别正则出:
bbs.csdn.net
www.bdyy.cc
www.qq.com


回复讨论(解决方案)

$s=<<<txthttp://bbs.csdn.net/topics/new?forum_id=PHPhttp://www.bdyy.cc/detail/?20236.htmlhttp://www.qq.com/html/?20236.html?id=88888txt;preg_match_all('/http:\/\/([^\/]+)\//s',$s,$matches);print_r($matches[1]);
Copy after login

Array
(
    [0] => bbs.csdn.net
    [1] => www.bdyy.cc
    [2] => www.qq.com
)

 preg_match('/http:\/\/([^\/]*)/i',$rrr,$matches);

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 Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template