编译失败:在偏移6处无需重复

sme*_*s24 3 php preg-match

我不知道为什么这不会工作...在多个regex跳棋和测试人员中完美地工作.但是当它运行它PHP我得到这个错误:

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
Run Code Online (Sandbox Code Playgroud)

即时运行:

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

Non*_*nym 6

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

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

直接取自PHP Docs:

Often used delimiters are forward slashes (/), hash signs (#) and tildes (~).
Run Code Online (Sandbox Code Playgroud)