PHP ʖ²ἯTH
º/A
XC. Regular Expression Functions (POSIX Extended)
½鉜
ע: PHP also supports regular expressions using a Perl-compatible syntax using the PCRE functions. Those functions support non-greedy matching, assertions, conditional subpatterns, and a number of other features not supported by the POSIX-extended regular expression syntax.
¾¯¸漯B
These regular expression functions are not binary-safe. The PCRE functions are.
Regular expressions are used for complex string manipulation in PHP. The functions that support regular expressions are:
ereg()
ereg_replace()
eregi()
eregi_replace()
split()
spliti()
Шdz
ΞШ͢²¿¿⎄¼þ¾ͿɒԼӈ뱾)չģ¿鵄֧³֡£
°²װ
To enable regexp support configure PHP --with-regex[=TYPE]. TYPE can be one of system, apache, php. The default is to use php.
ע: Do not change the TYPE unless you know what you are doing.
PHP µĠWindows °汾ґ¾Ěփ¸À©չģ¿鵄֧³֡£ĺΞШ¼Ӕ؈κθ½¼ӵĀ©չ¿⼴¿Ɋ¹ӃբЩº¯ʽ¡£
ԋАʱŤփ
¸À©չģ¿鎴¶¨ҥȎºΉ薃ָn¡£
Դ Ѝ
¸À©չģ¿鎴¶¨ҥȎºΗʔ´ Ѝ¡£
Ԥ¶¨ҥ³£
¸À©չģ¿鎴¶¨ҥȎºγ£¡£
·¶=
=ד 1. Regular Expression Examples
ereg ("abc", $string); /* Returns true if"abc" is found anywhere in $string. */ ereg ("^abc", $string); /* Returns true if "abc"; is found at the beginning of $string. */ ereg ("abc$", $string); /* Returns true if "abc" is found at the end of $string. */ eregi ("(ozilla.[23]|MSIE.3)", $HTTP_USER_AGENT); /* Returns true if client browser is Netscape 2, 3 or MSIE 3. */ ereg ("([[:alnum:]]+) ([[:alnum:]]+) ([[:alnum:]]+)", $string,$regs); /* Places three space separated words into $regs[1], $regs[2] and $regs[3]. */ $string = ereg_replace ("^", "br / ", $string); /* Put a br / tag at the beginning of $string. */ $string = ereg_replace ("$"," br / ", $string); /* Put a br /; tag at the end of $string. */ $string = ereg_replace ("\n", "", $string); /* Get rid of any newline characters in $string. */
Ϡ¹زο¼
For regular expressions in Perl-compatible syntax have a look at the PCRE functions. The simpler shell style wildcard pattern matching is provided by fnmatch().
Ŀ¼ ereg_replace -- Replace regular expression ereg -- Regular expression match eregi_replace -- replace regular expression case insensitive eregi -- case insensitive regular expression match split -- split string into array by regular expression spliti -- Split string into array by regular expression case insensitive sql_regcase -- Make regular expression for case insensitive match
º/A
ưµ㼯A
qdom_tree
ɏһ¼¶
ereg_replace