Delimiter must not be alphanumeric or backslash¶
Description¶
The first character of a regex is the delimiter, that delimits the regex. There is a first and a last delimiter.
In the case of this error, the first regex character is of invalid type. It cannot be alphanumeric (a-z, A-Z and digits), nore the backslash \.
Note that if the first characters are white spaces, such as space, tabulation, new line, they are ignored as potential delimiter.
Later, the NUL character (chr(0)) was added to the list of the forbidden characters.
Example¶
<?php
preg_match('a[bc]a', 'abc');
?>
Solutions¶
Use a non-alphanumeric character, like
/,#.
See Also¶
In more recent PHP versions, this error message is now Delimiter must not be alphanumeric, backslash, or NUL.