©
이 문서에서는 PHP 중국어 웹사이트 매뉴얼 풀어 주다
自 PHP 5.3.0起, POSIX 正则表达式扩展被废弃。在 POSIX 正则和 PCRE 正则之间有一些不同,本页列出了在转向PCRE 时最显著的需要知道的不同点。
POSIX | PCRE |
---|---|
ereg_replace() | preg_replace() |
ereg() | preg_match() |
eregi_replace() | preg_replace() |
eregi() | preg_match() |
split() | preg_split() |
spliti() | preg_split() |
sql_regcase() | 无对等函数 |
[#1] cdragon at dracoventions dot com [2013-07-21 03:48:59]
In regards to the previous comment that says "there are several other differences including different meaning for the symbols ( [ different rules for which symbols need escaping", as far as I can tell from reading
http://www.tin.org/bin/man.cgi?section=7&topic=regex
there are absolutely no "other differences" except in what the man page calls "Obsolete ("basic'') regular expressions". However, PHP doesn't appear to use the obsolete form of expressions in its POSIX functions.
PCRE even supports all of the POSIX named character classes such as [:space:].
[#2] jasen at treshna dot com [2011-10-26 15:11:38]
there are several other differences
including different meaning for the symbols ( [
different rules for which symbols need escaping (they can't be the same as both standard posix and extended posix)
you should read the full documentation for PCRE before chaging any posix regex to use pcre.