Regular expression fog, regular expression syntax Comparison among Various tools

Source: Internet
Author: User
Tags perl regular expression
In a variety of commonly used tools, regular expressions are similar but different. The following table lists some common regular expressions and their differences. There are always many projects and many omissions are required. please point out the missing items. The perl regular expression is used as the benchmark, and different usages are marked in pink. Grep2.5.1egrep2.5.1sed3.02sed4.07awk3.1.1perl5.8 regular expression

Among various commonly used tools,
Regular expressions are similar but different.
The following table lists some common regular expressions and their differences.
There are always many projects and many omissions are required. please point out the missing items.
The perl regular expression is used as the benchmark, and different usages are marked in pink.


Grep 2.5.1 Egrep 2.5.1 Sed 3.02
Sed 4.07
Awk 3.1.1 Perl 5.8.0 Vim 1, 6.1 JavaScript
??
Escape \ \ \ \ \ \ \
Line Header ^ ^ ^ ^ ^ ^ ^
End of line $ $ $ $ $ $ $
N \ \ Or \ only define -- posix or -- re-interval valid (to express} and not define -- posix or -- re-interval, the syntax is not used, \} \ {synonymous \
* * * * Or \ *, (to express *, use \\*) * * *
\ + + \ + + Or \ +, (to express +, use \ +) + \ + +
\? ? \? ? Or \?, (To express ?, Use \\?) ? \? ?
Any character . . . . Contains \ n. ./S after modification, \ n is included . Division \ n . Division \ n
(Pat) match and obtain results \ (Pat \) (Pat) \ (Pat \) (Pat) or \ (pat \) (to express parentheses, use \\(\\)) (Pat) \ (Pat \) (Pat)
(? : Pat) matched but not returned Not supported Not supported Not supported Not supported (? : Pat) Not supported (? : Pat)
(? = Pat) equal to pre-query Not supported Not supported Not supported Not supported (? = Pat) Not supported (? = Pat)
(?! Pat) unprecheck Not supported Not supported Not supported Not supported (?! Pat) Not supported (?! Pat)
| Or \ | | \ | | Or \ | (to express |, use \ |) | \ | |
Any character [Xyz] [Xyz] [Xyz] [Xyz] [Xyz] [Xyz] [Xyz]
[. Ch.] [= ch =] Not supported Not supported [. Ch.] Not supported Not supported Not supported Not supported
Word boundary \ B \ B \ B \ B Not supported \ B Not supported \ B
Non-word boundary \ B \ B \ B \ B Not supported \ B Not supported \ B
Left and right boundary of words <> \ <\> \ <\> \ <\> Not supported (> <和\> \ <和\\> \\ <同义< td> Not supported (> <和\> \ <同义< td> \ <\> Not supported (> <和\> \ <同义< td>
Control character/cx Not supported Not supported \ Cx Not supported \ Cx Not supported \ Cx
Number \ d Not supported Not supported Not supported Not supported \ D \ D \ D
Non-digit \ D Not supported Not supported Not supported Not supported \ D \ D \ D
Form Feed \ f Not supported Not supported High version support \ F \ F Other meanings \ f indicates the file name characters \ F
Newline \ n Not supported Not supported Not supported \ N \ N \ N \ N
Press enter \ r Not supported Not supported \ R \ R \ R \ R \ R
Blank \ s Not supported Not supported Not supported Not supported \ S \ S \ S
Non-blank \ S Not supported Not supported Not supported Not supported \ S \ S \ S
Tab \ t Not supported Not supported High version support \ T \ T \ T \ T
Vertical Tab \ v Not supported Not supported High version support \ V \ V Very magic \ V
Word character \ w [A-Za-z0-9 _] \ W \ W \ W Not supported \ W \ W \ W
Non-word character \ W [^ A-Za-z0-9] \ W \ W \ W Not supported \ W \ W \ W
\ Xn hexadecimal Not supported Not supported High version support \ Xn \ Xn Also, \ x indicates [0-9A-Za-z] \ Xn
\ N octal Not supported Not supported Not supported \ N \ N Not supported \ N
\ N back reference \ N \ N \ N \ N is available only for the result. \ N \ N is available only for the result. \ N
[: Alnum:] letters and numbers [: Alnum:] [: Alnum:] [: Alnum:] [: Alnum:] [: Alnum:] [: Alnum:] Not supported
[: Alpha:] Letters [: Alpha:] [: Alpha:] [: Alpha:] [: Alpha:] [: Alpha:] [: Alpha:] Not supported
[: Cntrl:] control characters [: Cntrl:] [: Cntrl:] [: Cntrl:] [: Cntrl:] [: Cntrl:] [: Cntrl:] Not supported
[: Digit:] number [: Digit:] [: Digit:] [: Digit:] [: Digit:] [: Digit:] [: Digit:] Not supported
[: Graph:] printable characters (excluding spaces) [: Graph:] [: Graph:] [: Graph:] [: Graph:] [: Graph:] [: Graph:] Not supported
[: Lower:] lower case [: Lower:] [: Lower:] [: Lower:] [: Lower:] [: Lower:] [: Lower:] Not supported
[: Print:] printable characters (including spaces) [: Print:] [: Print:] [: Print:] [: Print:] [: Print:] [: Print:] Not supported
[: Punct:] punctuation [: Punct:] [: Punct:] [: Punct:] [: Punct:] [: Punct:] [: Punct:] Not supported
[: Space:] space [: Space:] [: Space:] [: Space:] [: Space:] [: Space:] [: Space:] Not supported
[: Upper:] uppercase letters [: Upper:] [: Upper:] [: Upper:] [: Upper:] [: Upper:] [: Upper:] Not supported
[: Xdigit:] hexadecimal number [: Xdigit:] [: Xdigit:] [: Xdigit:] [: Xdigit:] [: Xdigit:] [: Xdigit:] Not supported
[: Return:] Not supported Not supported Not supported Not supported Not supported [: Return:] Not supported
[: Tab:] Not supported Not supported Not supported Not supported Not supported [: Tab:] Not supported
[: Escape:] Not supported Not supported Not supported Not supported Not supported [: Escape:] Not supported
[: Backspace:] Not supported Not supported Not supported Not supported Not supported [: Backspace:] Not supported

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.