Php 将eregi()替换为preg_match()语法错误

Php 将eregi()替换为preg_match()语法错误,php,syntax,preg-match,eregi,Php,Syntax,Preg Match,Eregi,我有几行php代码需要修改 while (eregi("([-]?)\"([^\"]+)\"", $a, $regs)) { 到 及 if(strlen($word)

我有几行php代码需要修改

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

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

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

我尝试了所有可能的(我可以)组合,我在谷歌上搜索过,在这里也搜索过,但没有找到答案。

您没有使用分隔符。。。。 你可以看看手册

试试这个“/([-]?)\”([^\“]+)\“/”(我只是在“/$pattern/”字符串的开头和结尾添加“/”)

if(strlen($word)<$min_word_length(!preg_match(“/$pattern/”),删除重音($word)))|($common[$word]==1)){

你没有使用分隔符……你可以看看手册。试试这个“/([-]?)\”([^\“]+)\“/”@laurac谢谢你的建议,你的行写得很好。你能不能也写第二行?很抱歉这么晚才回复。但是你很棒,为我节省了很多时间。真的非常感谢你。
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)) {
if (strlen($word) < $min_word_length || (!preg_match("/$pattern/", remove_accents($word))) || ($common[$word] == 1)) {