Learn about grep and VIM search and Regular Expressions

Source: Internet
Author: User

Grep does not support regular expression matching.

Egrep supports regular expression matching, but the extension does not.

Find Vim /? : Regular Expression matching is supported, but not extended.

 

Common examples:

Grep XXX 123.logBasic grep

Egrep name = 123. * Port = 80 search for rows containing name = 123 and Port = 80

VIM:/name = 123. * Port = 80 search for rows containing name = 123 and Port = 80

Vim can be used with other operations to complete some functions:

G/^ $/d find and delete empty rows

G/name = 123. * Port = 80/d find and delete rows containing name = 123 and Port = 80

 

 

Regular Expression to quickly adjust grep

Regular Expression: It is composed of a bunch of metacharacters. These metacharacters are combined according to certain rules to filter and match different contents. (In short, a regular expression is a filter composed of metacharacters)

Regular Expression Classification

1. Basic Regular Expression: a standard regular expression that supports basic metacharacters.

The metacharacters supported by the basic regular expression have the following meanings:

 

 

2. Extended Regular Expressions: More metacharacters are supported than the basic regular expressions, but the extended regular expressions do not support metacharacters supported by some basic regular expressions.

Extended Regular Expressions support metacharacters:

 

Through comparison, we will find that the metacharacters supported in basic regular expressions are not all supported in extended regular expressions.

Source: <understand grep and regular expressions-Linux->

 

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.