php - preg_match(): Delimiter must not be alphanumeric or backslash - but I use #? -


i above error - , have looked in post answer. thing use # delimiter , still error. have tried ~  , no other result.

$checkcode ="#^[a-z0-9]{8}$#";  if (preg_match($code, $checkcode)) {do stuff} 

what do wrong - or should error? lot ! ;) best regards, louise

you have use:

$re = "~^[a-z0-9]{8}$~";  $str = "...";   if(preg_match($re, $str, $matches)) { ...} // or if(preg_match($re, $str)) { ...} 

check documentation:

int preg_match ( string $pattern , string $subject [, array &$matches [, int $flags = 0 [, int $offset = 0 ]]] )


Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -