PHP escaped regular expression characters: preg_quote_php tutorial

Source: Internet
Author: User

PHP escaped regular expression character: Preg_quote


Preg_quote-escaping regular expression characters

String Preg_quote (String $str [, String $delimiter = NULL])

Preg_quote () requires the parameter str and adds a backslash to the character in each of the regular expression syntax. This is typically used when you have some run-time strings that need to be matched as regular expressions.

The regular expression special characters are:. \ + * ? [ ^ ] $ ( ) { } = ! < > | : -

Parameters

Str

Input string

Delimiter

If an optional parameter delimiter is specified, it is also escaped. This is typically used to escape the delimiter used by the Pcre function. /is the most common delimiter.

return value

Returns the escaped string.

Preg_quote () example

$keywords = ' $ g3/400 for a ';
$keywords = Preg_quote ($keywords, '/');
Echo $keywords; Returns \$40 for a g3\/400
?>

http://www.bkjia.com/PHPjc/951492.html www.bkjia.com true http://www.bkjia.com/PHPjc/951492.html techarticle PHP escaped regular expression character: Preg_quote Preg_quote escaped the regular expression character string preg_quote (string $str [, String $delimiter = NULL]) preg_qu OTE () requires the parameter str and ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.