The difference between php-pcre and POSIX regular expressions

Source: Internet
Author: User
Tags comparison table posix
POSIX Regular expression extensions have been deprecated since PHP 5.3.0. There are some differences between POSIX regular and PCRE, and this article lists the most significant differences that need to be known when steering PCRE.

The PCRE function requires that the pattern be closed with a delimiter.

Unlike the posix,pcre extension, there is no specific function for case-insensitive matching. Instead, support for the same work is done using the I (pcre_caseless) pattern modifier. Other pattern modifiers can also be used to change the matching policy.

The POSIX function looks for the longest match from the left, but PCRE stops after the first legal match. If the string does not match this is no different, but if the match, both in the result and speed will be different. To illustrate this difference, consider the following example (from Jeffrey Friedl, "Mastering regular Expressions"). Use mode one (self)? (selfsufficient)? Match on the string oneselfsufficient, PCRE will match to oneself, but with POSIX, the result will be the entire string oneselfsufficient. Two substrings match the original string, but POSIX will have the longest result.

function Comparison Table

Posix

PCRE

Ereg_replace () preg_replace ()

Ereg () Preg_match ()

Eregi_replace () preg_replace ()

Eregi () Preg_match ()

Split () Preg_split ()

Spliti () Preg_split ()

Sql_regcase () No equivalent function

  • 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.