grep Regular Expression

Source: Internet
Author: User
Tags grep regular expression

1.1) grep: is a text Search tool. The so-called metacharacters is not meant literal meaning, meta-character expression control or wildcard functions

2) Fgep:fast, does not support regular expressions, when literal representation.

"Grep"

1. Basic regular expression meta-characters:

. : Matches a single character.

[]: matches any single character within the specified range.

such as [0-9] = = = [[:d igit:]], [a-z] = = = [[: Lower:]], [a-z] = = = [[: Upper:]], [^]: Reverse

[[: Space:]]: space, [[:p UNCT:]]: special characters, [[: Alpha:]]: Uppercase and lowercase [[: Alnum:]]: Letters or numbers

2. Number of times match metacharacters: Specifies the number of occurrences of the preceding character

①*: Any length, the characters in front of him can appear any time

②\? : A single character appears 0 or one time

③\{m\}: Exact match appears m times

④\{m,n\}: Appears at least m times, up to N times

3. Position anchoring

Beginning: ^ Line end: $ word Left: \< word right:\>

A string of words that do not contain the characters of a continuous character of special characters

4. Grouping \ (* * * \) Once grouped, the group is considered an atomic unit

\#: Refers to the content that the # # brackets match to, not the pattern itself

5. Command options

-V: the inverse selection

-O: Only matching strings are displayed, not the lines where the strings are located

-I: Ignore case

-e: extending regular expressions

-A: Displays the following line

-B: Display the line above

-C: Display context

In the extended regular expression are also:

+: match at least once

grep 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.