2011-08-04 62 views
0

我的PHP代码行,我需要改变替换的preg_match()语法错误eregi()

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)) { 

我尝试了所有可能的(我可以)组合,我在谷歌搜索和这里也找不到。

+0

你没有使用分隔符....你可以看到手册http://www.php.net/manual/en/regexp.reference.delimiters.php。试试这个” /([ - ]?)\ “([^ \”] +)\ “/” – laurac

+0

@laurac感谢您的建议,您的书面线只是工作完美。你能否写下第二行呢? – Anuj

+0

检查答案:) – laurac

回答

1

你没有使用分隔符.... 你可以看到手册php.net/manual/en/regexp.reference.delimiters.php。 (/ - []])/“(”我只在字符串的开头和结尾添加“/”/ $模式/“)

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

对不起,这么晚回复。但你很棒,为我节省了很多时间。非常感谢你。 – Anuj