Thursday, 14 July 2011

CakePHP preg_match Error

Warning (2): preg_match() [function.preg-match]: Delimiter must not be alphanumeric or backslash...
If you have met a warning similar with above, you will have to check on the $pattern of the preg_match() function. According to php manual:

When using the PCRE functions, it is required that the pattern is enclosed by delimiters. A delimiter can be any non-alphanumeric, non-backslash, non-whitespace character. 

So if your $pattern is a pure alphanumeric string,you will need to enclose the $pattern with delimiters such as / , or # or etc.

No comments: