2011-12-10 33 views
3

我不知道为什么这不会工作......完美地在多个正则表达式检查器和测试器中工作。但是,当涉及到在PHP中运行它,我得到这个错误:编译失败:没有重复的偏移量6

Warning: preg_match() [function.preg-match]: Compilation failed: nothing to repeat at offset 6 in /home/splose/public_html/index/index.php on line 49 

IM运行以下命令:

if(preg_match('[\\/^$.|?*+():<>]', $username)){} 
+1

我相信你必须用正斜杠开始并结束你的正则表达式'/'否? –

回答

5

或许你可以尝试划你的模式?:

if(preg_match('/[\\/^$.|?*+():<>]/', $username)){} 

采取直接从PHP Docs

Often used delimiters are forward slashes (/), hash signs (#) and tildes (~). 
+0

唉欢呼,它的工作!我以为我尝试使用分隔符。无论如何感谢堆。 – smeddles24

相关问题