📖
정규식 1차 도메인만 추출

페이지 정보

본문

[code]<?php
$domain="www.naum.kr";
preg_match('/[^\.]+\.([^\.]{4}|[^\.]{3}|(co|or|pe|ac)\.[^\.]{2}|[^\.]{2})$/i', $domain, $matches);
print_r($matches);
?>[/code]결과 : Array ( [0] => naum.kr [1] => kr )
[code]<?php
$domain = "http://aaa.www.domain.net";
$pattern = "/[a-z]+\.([a-z]|co\.kr)+$/si";
preg_match($pattern, $domain, $match);
?>[/code]결과 : $match[0] : domain.net

댓글목록

등록된 댓글이 없습니다.


🔍 검색

회사소개 개인정보처리방침 서비스이용약관
Copyright © rainbowgarden.shop All rights reserved.