Home > Backend Development > PHP Tutorial > 如何用正则截取域名中间的部分

如何用正则截取域名中间的部分

WBOY
Release: 2016-06-13 10:28:26
Original
1787 people have browsed it

怎么用正则截取域名中间的部分
比如 www.baidu.com abc.baidu.com www.baidu.com.cn 后缀有很多种 要求能都截取中间的 baidu

------解决方案--------------------

PHP code
$s = 'www.baidu.com abc.baidu.com www.baidu.com.cn';preg_match_all('/(\w+)\.com/i', $s, $r);print_r($r);<div class="clear">
                 
              
              
        
            </div>
Copy after login
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