RE: Regular Expression

Source: Internet
Author: User
Tags alphabetic character printable characters egrep

Regular expression (RE):
Basic Regular Expression BRE:grep and sed use,egrep and awk use
extended Regular expression:egrep and awk use

meaning of the basic special characters:
^tux matches lines starting with Tux (must appear first in sed and grep )
tux$ matches lines ending with Tux (the last one must appear in sed and grep )
. Matches any single character except newline characters (can match line breaks inawk )
*match a previous character 0 or more times (including the preceding character)
.*Match any character 0 or more times
[] matches any one of the characters contained in [XXX] , except for the following three, the other special characters are ordinary characters in [] .
[\x]use \ in [] to relay the meaning of special characters
[^x] matches any one of the characters not contained in [^xxx]
[x-x] matches any character in the specified range in [M-n]
\{n\}Matches the previous character N times (including the preceding character)
\{n,\}matches the preceding character at least n times (including the preceding character)
\{n,m\}matches the preceding character at least n times, up to m times (including the preceding character)
\escape character, convert special character to normal character


Extended Special character meanings: (used byegrep and awk )
+ match one of the preceding characters 1 or more times (including the preceding character)
? Match one of the preceding characters 0 or 1 occurrences (including the preceding character)
|specifies that a regular expression can be matched before or after it, that is, or
() Grouping of regular expressions, () you are considered as a whole
{n}Matches the previous character N times (including the preceding character)
{n,}matches the preceding character at least n times (including the preceding character)
{n,m}matches the preceding character at least n times, up to m times (including the preceding character)


Description: If it matches the previous character 0 times, including the preceding character: that is, 0 times in the pattern of the * before the character to be removed.

character class (for [] ):
[: alnum:] printable characters (including white space characters)
[: Alpha:] alphabetic character
[: blank:]Spaces and Tabs
[: Cntrl:] control character
[:d igit:] numeric characters
[: graph:] graphic characters (excluding space characters)
[: Lower:] lowercase characters
[:p rint:] printable characters (including white space characters)
[:p unct:] punctuation characters
[: space:] white space characters
[: Upper:] Uppercase characters
[: xdigit:] hexadecimal character


To be Continued ...

RE: Regular Expression

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.