Python-why does the 'preg' of PHP require regular expressions with delimiters?

Source: Internet
Author: User
Tags preg
Is it because I learned from Perl? However, Perl is a language embedded with regular expressions. It is natural to use separators to indicate regular expressions. Since PHP uses preg functions, why do I need separators? Function processing is also used in Python (provided by the re module) without separators. {Code...} Haskel... is it because of learning from Perl? However, Perl is a language embedded with regular expressions. It is natural to use separators to indicate regular expressions. PHP is used pregWhy do you need separators for Series function processing?

In Python, function processing is also used (reModule), no separator is required.

pattern = re.compile("foo")

In HaskellText.Regex.PosixYou do not need to use separators.

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

Interestingly, PHP 5.3 is obsolete.eregSeries functions do not contain delimiters:

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

SopregWhen designing a series of functions as pattern, you need to add delimiters. What is the purpose?

Reply content:

Is it because I learned from Perl? However, Perl is a language embedded with regular expressions. It is natural to use separators to indicate regular expressions. PHP is usedpregWhy do you need separators for Series function processing?

In Python, function processing is also used (reModule), no separator is required.

pattern = re.compile("foo")

In HaskellText.Regex.PosixYou do not need to use separators.

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

Interestingly, PHP 5.3 is obsolete.eregSeries functions do not contain delimiters:

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

SopregWhen designing a series of functions as pattern, you need to add delimiters. What is the purpose?

Some pattern modifiers can be added with separators.m,u,i,sAnd so on. How can I add a separator without it? AndpregThe series followsPCRESeries, so followPCRESome basic rules,POSIXDo not use separators. In additionpregSeries andperlThere are some differences, so it should not beperlLearn it.

References:
Differences between PCRE and perl
Differences between PCRE and POSIX Regular Expressions
Available pattern modifiers 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.