Linux Regular Expressions (awk, sed, grep)

Source: Internet
Author: User

Regular expressions: Regular expressions are a set of rules and methods that are defined for processing a large number of strings.

Regular expressions are widely used in almost all languages (e.g. Java, C, C + +, PHP, Python, etc.)


==================== Basic Regular =====================

^ Match with what to start with, ^w matches content starting with W

$ match with what ends, $w matches content ending with W

^$ Matching Blank lines

. Represents and can only represent any one character

\ escape character, such as \. Represents only.

* Repeat 0 or more of the preceding characters

. * Match All characters

Regular ==================== of ===================== strengthening

[ABC] matches any character in a character set

[^ABC] matches the content of any character that does not contain ^, the ^ in parentheses is the inverse
---------------need to use Egrep or sed-r if you do not use these two command brackets need to be escaped-----------

A{N,M} match repeats N to M times

A{n,} match repeats at least n times

A{n} match repeats n times

A{,M} match repeats up to M times
===================== Extended Regular =====================

+ denotes repeating "one or more" preceding characters

? Represents repeating "0 or one" preceding characters

| means filtering multiple strings at the same time

() group filtering, referencing backward


Linux Regular Expressions (awk, sed, grep)

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.