PHP-PCRE regular expression separator

Source: Internet
Author: User
PHP extension text processing -- PCRE regular expression syntax 1 -- delimiter when using the PCRE function, the mode needs to be closed by the delimiter. The delimiter can be any non-alphanumeric, non-backslash, or non-blank character.

Frequently used delimiters are forward slashes (/), hash symbols (#), and reverse symbols (~). The following examples use valid delimiters.

/Foo bar/# ^ [^ 0-9] $ # + php + % [a-zA-Z0-9 _-] %

If the delimiter needs to be matched in the mode, it must be escaped using a backslash. If separators often appear in the mode, a better choice is to use other separators to improve readability.

/Http: \/# http ://#

You can use the preg_quote () function to escape a string to be used in the mode. its second parameter (optional) can be used to specify the separator to be escaped.

In addition to the separators mentioned above, you can also use the separators in the bracket style. the left and right brackets are used as the start and end separators respectively.

{This is a pattern}

You can add a pattern modifier to the end separator. The following example shows a case-insensitive match:

# [A-z] # I

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.