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
  • 193
  • 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
  • 40,904
  • 21
  • 118
  • 94
  • It is good to mention that they do not have to be `/` - it can be any symbol. Like the one he has - regexp starts with `^` and expects `^` at the end. – Cheery Oct 17 '14 at 00:54