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

gcc - MinGW's ld cannot perform PE operations on non PE output file -

How to connect android app to App engine -

hadoop - Running Map Reduce Job shows error - Mkdirs failed to create /var/folders/ -