The characteristics of Linux regular expressions and the similarities and differences between BRE and ere--regular expressions

Source: Internet
Author: User
Tags character set posix

Linux Regular Expressions (Regular Expression) are primarily compliant with POSIX BRE or POSIX-ere standards. What is POSIX, the POSIX portable operating system Interface Portable Operating System interface is a BRE extended version, with more specific processing power, and an added number of meta characters (Metacharactor).

  BRE's main competency sets are:

1 ordinary character (Literal text), such as A,b,c

2 nonprinting characters, including tab, carriage return, newline, carriage return line (WINDOWS)

3) any character.

4 Character set, including Word type characters ([: Alnum:]), non-word characters ([^[:alnum:]]), numbers ([[[:d Igit:]]), Non-numeric ([^[:alnum:]]), whitespace, TAB, newline, and other white space characters ([[: Space:]] ) and Non-white-space characters ([^[:space:]])

5 Edge match, whether Bre or Ere, only supports matching start or end of line, unlike Perl, you can also match word head and word tail

6) Matching repeat number (quantifier/repetition)

7) grouping and back reference

8 Polynomial matching (alteration), using Metacharacters |, the feature is only ere supported, Bre does not have this feature

Bre and Ere seemed to support both ASCII and Unicode pending confirmation;

Forward lookup and negative forward lookup are not supported;

Forward lookup and negative back lookup are not supported;

Bre and ere in ability differ only in the ability of many matches, the other aspect has no big difference, the main difference is embodied in the meta character.

BRE defines only 4 sets of metacharacters:

[] used to select a character to match in multiple characters, [] there can be-to show the range, but-not itself a meta character

. Used to match any character

^ The meaning of "non" when used for matching, and one use is to match the beginning of a line

$ for matching end of line

Ere this added the definition of 3 sets of metacharacters:

{} is used to indicate the number of duplicate matches. Only {} is treated as a normal character in Bre, to use this feature must be escaped with \, that is, "\{\}"

() for grouping. Only () is treated as a normal character in Bre and must be escaped using this feature, that is, "\ (\)"

| Completely for the addition of the new multiple matching capabilities defined, Bre no multiple matching capabilities, only to be treated as ordinary characters

The above content is a small series to introduce the Linux regular expression features detailed and Bre and ere the difference, I hope you like.

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.