Python-Why does PHP's ' preg ' require a regular delimiter?

Source: Internet
Author: User
Tags ereg modifiers posix preg
Is it because of a study with Perl? But Perl is the language of inline regular expressions, and it is natural to use delimiters to indicate the regular. Since PHP is used pregSeries function processing, why do you use separators?

Python is also treated with a function ( re provided by the module) and does not require delimiters.

pattern = re.compile("foo")

As in Haskell, Text.Regex.Posix separators are not required.

"my left foot" =~ "foo" :: Bool

Interestingly, the series functions that began to be deprecated in PHP 5.3 ereg are non-delimited:

eregi("(ozilla.[23]|MSIE.3)", $_SERVER["HTTP_USER_AGENT"]);

So preg what is the purpose of a series of functions that are designed to be pattern-delimited?

Reply content:

Is it because of a study with Perl? But Perl is the language of inline regular expressions, and it is natural to use delimiters to indicate the regular. Since PHP is processed with a preg series of functions, why use separators?

Python is also treated with a function ( re provided by the module) and does not require delimiters.

pattern = re.compile("foo")

As in Haskell, Text.Regex.Posix separators are not required.

"my left foot" =~ "foo" :: Bool

Interestingly, the series functions that began to be deprecated in PHP 5.3 ereg are non-delimited:

eregi("(ozilla.[23]|MSIE.3)", $_SERVER["HTTP_USER_AGENT"]);

So preg what is the purpose of a series of functions that are designed to be pattern-delimited?

If you add a delimiter, you can add some pattern modifiers,, and so on, how do you m u i s add delimiters? And the preg series of words is the lineage PCRE series, so follow PCRE the basic rules, it POSIX is not the delimiter. The other preg series and perl a little different, so should not follow perl the study it.

Resources:
The difference between Pcre and Perl
The difference between pcre and POSIX regularization
Pattern modifiers available in regular expressions

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