티스토리 뷰

POSIX를 통한 정규표현식이 PHP 7.0.0. 부터 제거 되었기 때문에

PCRE를 사용하여야 한다. ( fnmatch()도 가능 )

http://docs.php.net/manual/en/book.pcre.php

http://docs.php.net/manual/en/ref.pcre.php

 

PHP: PCRE - Manual

There are no user contributed notes for this page.

docs.php.net

 

preg_match와 preg_match_all의 차이는 JS에서 사용되는 querySelector()와 querySelectorAll()의 차이와 같다.

preg_match는 처음 매치가 발생하면 후위 검색을 하지 않는 반면,

perg_match_all은 끝까지 패턴 일치 string이 있는지 확인한다.

 

preg_match( string $pattern, string $subject, array &$matches  )

 

결과값을 $matches를 통해 반환한다.

 

preg_filterpreg_replace는 패턴에 맞는 문자열을 변환하여 준다.

 

 

 

댓글