更新时间:2023-02-18 17:07:54
ereg
已过时.不要使用它.preg
函数都是"Perl正则表达式",这意味着您需要在正则表达式上具有某种开始和结束标记.通常是/
或#
,但是任何非字母数字都可以.ereg
is deprecated. Don't use it.preg
functions are all "Perl regular expressions" meaning you need to have some sort of beginning and end marker on your regex. Often this will be /
or #
, but any non alpha-numeric will do fine.例如,这些将起作用:
preg_match("/foo/u",$needle,$haystack);
preg_match("#foo#i",$needle,$haystack);
preg_match("@foo@",$needle,$haystack);
preg_match("\$foo\$w",$needle,$haystack); // bad idea because `$` means something
// in regex but it is valid anyway
// also, they need to be escaped since
// I'm using " instead of '
但这不会:
preg_match("foo",$needle,$haystack); // no delimiter!