15th-Shell Regular Expressions

Source: Internet
Author: User
Tags alphabetic character perl regular expression posix uppercase letter

15th-Shell Regular Expressions

See picture

Classification of regular expressions for Shell regular expressions
    1. Basic Regular Expressions (basic Regular expression also known as basic RegEx abbreviation Bres)
    2. Extended Regular expression (Extended Regular expression also known as Extended RegEx abbreviation Eres)
    3. Perl Regular Expressions (Perl Regular expression called Perl RegEx abbreviation pres)
Basic components

The basic component of a regular expression.

Regular Expressions Description Example Basic RegEx Extended RegEx Python RegEx Perl regEx
\ Escape characters, escaping special characters, ignoring their special meanings A\. b matches a.b, but does not match AJB, point is escaped as a special meaning \ \ \ \
^ Matches the beginning of the line, awk, ^ is the start of the string ^tux matches lines starting with Tux ^ ^ ^ ^
$ Matches the end of the line, in Awk, $ is the ending of the matching string tux$ matches lines ending with Tux $ $ $ $
. Matches any single character except the line break \ n, in awk you can AB. Match ABC or ABD, not matching ABCD or Abde, only match single character . . . .
[] Match any one of the characters contained in [character] COO[KL] can match cook or cool [] [] [] []
[^] Match any character other than [^ character] 123[^45] can not match 1234 or 1235,1236/1237 [^] [^] [^] [^]
[-] Matches any one of the specified Fan Wenne characters in [], to be written as incrementing [0-9] can match 1, 2, or 3 of any one of the numbers [-] [-] [-] [-]
? Match previous items 1 or 0 times Colou?r can match color or colour, and cannot match Colouur Not supported ? ? ?
+ Match the previous item 1 or more times sa-6+ matches sa-6, sa-666, cannot match sa- Not supported + + +
* Match the previous item 0 or more times Co*l matches cl, col, cool, coool, etc. * * * *
() Match expression to create a substring for matching * * * * * Max (tri)? Match Max or Maxtri Not supported () () ()
N Matches the previous item n times, n is a positive integer that can be 0 [0-9] {3} matches any three-digit number and can be expanded to 3 [0-9] Not supported N N N
{N,} The previous item must match at least n times [0-9] {2,} matches any one two-digit or multiple-digit number Not supported {N,} {N,} {N,}
{N,m} Specifies that the preceding item matches at least N times, up to M times, n<m [0-9] {2,5} matches any number from a two-digit to a five-digit number Not supported {N,m} {N,m} {N,m}
| Alternate Match | Any one of two sides AB (C|D) matches ABC or ABD Not supported | | |
POSIX character class

The POSIX character class is a special meta-sequence (meta sequence) of a shape such as [: ...:] that can be used to match a specific range of characters.

Regular Expressions Description Example Basic RegEx Extended RegEx Python RegEx Perl regEx
[: Alnum] Match any one letter or number character [[: Alnum]]+<br/> Matches one or more letters or numbers [: Alnum] [: Alnum] [: Alnum] [: Alnum]
[: Alpha:] Match any alphabetic character (including uppercase and lowercase letters) [[: Alpha:]] {4}<br/> matches any of 3 letters [: Alpha:] [: Alpha:] [: Alpha:] [: Alpha:]
[: Blank:] Spaces and tabs (Landscape and portrait) [[: Blank:]]*<br/> matches 0 or more spaces and tabs [: Blank:] [: Blank:] [: Blank:] [: Blank:]
[:d Igit:] Match any numeric character [[:d igit:]]?<br/> Match 0 or 1 digits [:d Igit:] [:d Igit:] [:d Igit:] [:d Igit:]
[: Lower:] Match lowercase letters [[: Lower:]] {5,}<br/> matches at least 5 lowercase letters or more than 5 lowercase letters [: Lower:] [: Lower:] [: Lower:] [: Lower:]
[: Upper:] Match uppercase letters ([[: upper:]]+)? <br/> Matches an uppercase letter or multiple uppercase letters 0 or 1 times. [: Upper:] [: Upper:] [: Upper:] [: Upper:]
[:p UNCT:] Match punctuation [[:p UNCT:]] [[:p UNCT:]] [[:p UNCT:]] [[:p UNCT:]] [[:p UNCT:]]
[: Space:] Matches all whitespace characters including line feed, carriage return, and so on [[: space:]]+ [: Space:] [: Space:] [: Space:] [: Space:]
[: Graph:] Matches any character that can be seen and can be printed [[: Graph:]] [: Graph:] [: Graph:] [: Graph:] [: Graph:]
[: Xdigit:] Any one hexadecimal number (i.e.: 0-9,a-f,a-f) [[: xdigit:]]+ [: Xdigit:] [: Xdigit:] [: Xdigit:] [: Xdigit:]
[: Cntrl:] Any one control character (the first 32 characters in the ASCII character set) [[: Cntrl:]] [: Cntrl:] [: Cntrl:] [: Cntrl:] [: Cntrl:]
[:p rint:] Any one of the characters that can be printed [[:p rint:]] [:p rint:] [:p rint:] [:p rint:] [:p rint:]
Metacharacters

Metacharacters (meta character) is a Perl-style regular expression that is supported by only a subset of text processing tools, not all text processing tools.

Regular Expressions Description Example Basic RegEx Extended RegEx Python RegEx Perl regEx
\b Word boundaries \bcool\b matching cool, mismatched coolant \b \b \b \b
\b Non-word boundary cool\b matching coolant, not matching cool \b \b \b \b
\d Single numeric character B\DB match Business-to-business, mismatch BCB Not supported Not supported \d \d
\d Single non-numeric characters B\db matching BCB, mismatch business-to-business Not supported Not supported \d \d
\w Single word characters (letters, numbers, and _) \w matches 1 or A or _, does not match @ \w \w \w \w
\w Single non-word character \w matches @, does not match 1 or a or _ \w \w \w \w
\ n Line break \ n matches a new row Not supported Not supported \ n \ n
\s Single whitespace character X\SX matches x x, does not match xx Not supported Not supported \s \s
\s Single non-whitespace character X\SX matches Xkx, does not match xx Not supported Not supported \s \s
\ r Enter \ r Match Carriage return Not supported Not supported \ r \ r
\ t Horizontal tab \ t matches a horizontal tab Not supported Not supported \ t \ t
\v Vertical tab \v matches a vertical tab Not supported Not supported \v \v
\f Page break \f Match a page break Not supported Not supported \f \f

15th-Shell Regular Expressions

Related Article

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.