Integration and significance of the basic regular expression metacharacters in Ubuntu

Source: Internet
Author: User

Ubuntu's basic regular expression metacharacters and meanings: "*" ------ used to match the previous normal character 0 or multiple times; ". "------ used to match any character;" ^ "------ used to match the first line, indicating the character (or string) after the character" ^ "at the beginning of the line ); "$" ------ used to match the beginning and end, $ is placed after the matching character, opposite to the function and usage of the "^" symbol; "[]" ------ used to match character sets, this symbol supports the exhaustive method to list all elements of a character set. It also supports the use of the "-" symbol to indicate the range of character sets, indicating that the range of character sets starts from the Left character, ends with the character on the right side of "-". example-01: the exhaustive method is used to list character set combinations: sudo find/etc/-name *. conf | grep [abc] use the "-" symbol to indicate the word set range: sudo find/etc/-name *. conf | grep [a-d] example-02: sudo f Ind/etc/-name *. conf | grep [^ a-d] In the above example, "^" indicates the reverse meaning, no longer the meaning of matching the first character of the line; "\" ------ is an escape character, it is used to block the special meaning of a metacharacters and to interpret the metacharacters after the "\" symbol by literal meaning. example: sudo find/etc/-name *. conf | grep \. in the example above, it no longer indicates matching any character, but only indicates the character itself. "\ <\>" ------ Is a exact match symbol, which uses the "\" symbol to shield the "<>" symbol; "\ {\}" ------ the series symbols are similar to "*", indicating the repetition of the previous character. However, the "*" symbol indicates zero or any repetition, and the "\ {\}" series symbol can specify the number of repetitions, the "\ {\}" series symbols can be in the following three forms. 1. \ {n \}: match the previous character to appear n times; 2. \ {n, \}: match the previous character to appear at least n times; 3. \ {n, m \}: match the previous character to appear n to m times.

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.