0

The first preg_match is line 32. I imagine the second preg_match is going to give the same error. How do I fix this? Thanks.

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('^([1-zA-Z0-1@.\s]{4,30})$', $passwordCreation)) {
icor103
  • 161
  • 1
  • 8

1 Answers1

1

Use delimiters (/) at the beginning and end of regexes:

if (preg_match('/^(?=.{4,20}$)(?![_.])(?!.*[_.]{2})[a-zA-Z0-9._]+(?<![_.])$/', 
$userCreation)) {
    if(preg_match('/^([1-zA-Z0-1@.\s]{4,30})$/', $passwordCreation)) {
Gergo Erdosi
  • 39,090
  • 21
  • 113
  • 91