用preg_match()语法错误替换eregi()


Replace eregi() with preg_match() syntax error

我有几行php代码需要修改

while (eregi("([-]?)'"([^'"]+)'"", $a, $regs)) { 

while (preg_match("([-]?)'"([^'"]+)'"", $a, $regs)) {

if (strlen($word) < $min_word_length || (!eregi($pattern, remove_accents($word))) || ($common[$word] == 1)) {

if (strlen($word) < $min_word_length || (!preg_match($pattern, remove_accents($word))) || ($common[$word] == 1)) {

我尝试了所有可能的(我可以)组合,我在谷歌和这里也搜索过,但无法找出

您没有使用分隔符....您可以查看手册php.net/manual/en/regexp.reference.delimiters.php。

试试这个 "/([-]?)'"([^'"]+)'"/" ( 我只添加"/"开始和结束的字符串/模式/美元)

if (strlen($word) < $min_word_length || (!preg_match("/$pattern/", remove_accents($word))) || ($common[$word] == 1)) {