2014-10-17 65 views
0

第一个preg_match是第32行。我想象第二个preg_match会给出同样的错误。 我该如何解决这个问题?谢谢。正则表达式难度

Warning: preg_match(): No ending delimiter '^' found in 
C:\xampp\htdocs\(...)\index.php on line 32 



if (preg_match('^(?=.{4,20}$)(?![_.])(?!.*[_.]{2})[a-zA-Z0-9._]+(?<![_.])$', 
$userCreation)) { 
    if(preg_match('^([[email protected]\s]{4,30})$', $passwordCreation)) { 
+0

问题的标题写作的难度? – mario 2014-10-17 01:10:11

回答

1

使用分隔符(/)在正则表达式的开头和结尾:

if (preg_match('/^(?=.{4,20}$)(?![_.])(?!.*[_.]{2})[a-zA-Z0-9._]+(?<![_.])$/', 
$userCreation)) { 
    if(preg_match('/^([[email protected]\s]{4,30})$/', $passwordCreation)) { 
+0

很高兴提及它们不必是'/' - 它可以是任何符号。就像他所拥有的那样 - 正则表达式以'^'开始,最后期望'^'。 – Cheery 2014-10-17 00:54:22

+0

@Cheery是的,谢谢你的提示。 – 2014-10-17 00:58:43