PHP Regular Expression Learning notes (the difference between several common functions)

Source: Internet
Author: User

The difference between the Preg_mache () function and the Preg_mache_all () function:

Preg_mache () matches only the characters in the rule once, and Preg_mache_all () matches all characters that match the criteria!

Example comparison:

The difference between the Preg_replace () and the Preg_filter () of the regular expression function:

  Preg_replace () retains the replaced data, and Preg_filter () retains the replacement and the data that has not been replaced . To make an analogy:

String: ABC has a b match replaced, then Preg_replace () will get "replaced data", Preg_filter () will get "a replaced data B".

Preg_grep of the regular Expression function ():

Only do match, do not replace!!!! Show only the matching data!!!

Preg_split of the regular Expression function ():

splitting a string according to a matching rule functions like the explode () function , with the following effect:

Preg_quote of the regular Expression function ():

Escapes the target. Example:

Function Summary:

PHP Regular Expression Learning notes (the difference between several common functions)

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.