The preg_last_error function is used to escape regular expression characters.
string preg_quote ( string $str [, string $delimiter = NULL ] )
preg_quote() takes the parameter str and adds a backslash before each character in the regular expression syntax. This is typically used when you have some runtime strings that need to be matched as regular expressions.
Regular expression special characters are: . + * ? [ ^ ] $ ( ) { } = ! < > | : -
Parameter description:
$str: input string.
$delimiter: If the optional parameter delimiter is specified, it will also be escaped. This is typically used to escape delimiters used by the PCRE function. / is the most common delimiter.
Returns the escaped string.
The execution result escapes the $ and / special characters as follows:
Return$40 for a g3/400
The execution result is as follows:
This book is <i>*very*</i> difficult to find.