Linux Extended formal notation

Source: Internet
Author: User

+ Meaning: Repeat the previous re character of "one or more"
Example: Search (God) (good) (Goood) ... And so on the string. The o+ represents "more than one o" so the bottom of the running results will be the 1th, 9, 13 ranks out.
egrep-n ' go+d ' regular_express.txt
? Meaning: "0 or one" of the previous RE character
Example: Search (GD) (God) these two strings. The O? stands for "Empty or 1 O" So, the above results will be the 13th, 14 ranks out. Have you found that the result set of these two cases (' go+d ' and ' go?d ') is the same as ' go*d '? Think about it, this is why Oh! ^_^
egrep-n ' go?d ' regular_express.txt
| Meaning: Finding several strings in a way or (or)
Example: Search for GD or good these two strings, note that is "or"! So, the first three lines of 1,9,14 can be printed out Oh! What if you still want to find the dog?
egrep-n ' Gd|good ' regular_express.txt
Egrep-n ' Gd|good|dog ' regular_express.txt
() Meaning: Find the "group" string
Example: Search (Glad) or (good) these two strings, because G and D are duplicates, so I can put LA and oo in (), and by | To separate, it's OK!
Egrep-n ' g (la|oo) d ' Regular_express.txt
()+ Meaning: discrimination of multiple repeating groups
Example: Call "Axyzxyzxyzxyzc" with Echo, and then use the following method to search for it!
echo ' axyzxyzxyzxyzc ' | egrep ' A (xyz) +c '
above the example means that I'm going to look at the beginning is a end is C, in the middle there is more than one "xyz" string meaning ~

Linux Extended formal notation

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.