string pcregrep_lib(string regex, string text [,int opt])
Description
시스템의 grep 과 비슷한 역할을 한다. text 에 주어진 문자열에서 regex 와 매치되는 행을 변수로 받는다. opt 를 1 로 주었을 경우, regex 와 매치되지 않는 행만 변수로 받는다.
정규식은 pcre 호환 정규식이 적용이 된다.
Arguments
(string) regex - matching condition
(string) text - raw data
(int) opt (optional) - revert condition
Example
<?php$a =<<<EOFI'm a boyYou are the studentAm I Oh happy?Oh no, I'm crazyOh no, I'M sexy girlEOF;echopcregrep_lib ('/I\'m/i', $a);/* RESUTL:I'm a boyOh no, I'm crazyOh no, I'M sexy girl */echopcregrep_lib ('/I\'M/', $a);/* RESULT:Oh no, I'M sexy girl */echopcregrep_lib ('/I\'M/', $a,1);/* RESULT:I'm a boyYou are the studentAm I Oh happy?Oh no, I'm crazy */echopcregrep_lib('/^I/', $a,1);/* RESULTYou are the studentAm I Oh happy?Oh no, I'm crazyOh no, I'M sexy girl */?>