int preg_match ( string $pattern , string $subject [, array &$matches [, int $flags [, int $offset ]]] )
Searches subject for a match to the regular expression given in pattern .
int ereg ( string $pattern , string $string [, array &$regs ] )
Searches a string for matches to the regular expression given in pattern in a case-sensitive way.
当使用preg_match的时候,需要用前后结束符将正则表达式括起来;而ereg时候,就使用双引号就可以了。
本文对比了ereg与preg_match两个PHP函数在正则表达式匹配上的不同之处。ereg使用双引号包裹正则表达式,而preg_match则需要使用特殊字符来界定正则表达式的开始与结束。
189

被折叠的 条评论
为什么被折叠?



