php 编译失败:在偏移 6 处无需重复
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8454564/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 04:45:40 来源:igfitidea点击:
Compilation failed: nothing to repeat at offset 6
提问by smeddles24
im not sure why this wont work... works perfectly in multiple regex
checkers and testers. but when it comes to running it in PHP
i get this error:
我不知道为什么这不起作用......在多个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
im running this:
我正在运行这个:
if(preg_match('[\/^$.|?*+():<>]', $username)){}
回答by Nonym
回答by yanwen li
I think you should use regex expression with delimiters forward slashes (/)
我认为您应该使用带有分隔符正斜杠 (/) 的正则表达式
// wrong pattern
$pattern = '[\/^$.|?*+():<>]';
// right pattern
$pattern = '/[\/^$.|?*+():<>]/';
if(preg_match($pattern, $username)){}