Regular expressions in the shell

Source: Internet
Author: User
Tags lowercase

Regular Expressions (regular Express)The expression of a rule, which is to represent data with the same characteristics with some pre-defined symbols, almost all programming languages use regular expressions (regular) and are common in different programming languages.
Regular points Standard RegularExtended Regular, the extension is more simple and flexible to make some modifications and expansions in the basic regular rules, while the few parts only support standard regular. So when we write the regular, we prioritize the extended regular if we don't support the standard regular.

Standard Regular

[] two brackets denote the collection, all parameters written in the collection must have and only one match, successive characters can be used-the connection such as [A-z] denotes any lowercase letter [a-z] any one of the uppercase letters [0-9] any number

. Dots represent Any character, letters, numbers, and special symbols all match

^ The sharp angle indicates that a rule with the beginning of a match followed by a rule indicating that the beginning of the rules, such as ^[a-z], begins with a lowercase letter. if ^ inside [^] denotes the meaning of the inverse, for example [^a-z] means not to start with a lowercase letter alone

The $ dollar sign denotes what ends with a preceding rule ending for example [a-z]$ = lowercase letter ending ^$ means blank line

\{n,m\} indicates that one of the preceding rule matches n is the minimum number of times m is the maximum number of times \{n,\} m does not write a value greater than or equal to n times \{n\}, and M do not write to indicate that exact match n times cannot be used alone

* asterisks indicate matching the previous rule 0 times and above and cannot be used alone , for example [0-9][0-9]* indicates a matched positive integer

The \ (\) brackets indicate that the rules in parentheses are integrated into a whole, and that they can be referenced by the position of the brackets after they remain in a staging area, for example (a) b\1 indicates that ABA (AD) b (c) \1\2 represents ADBCADC

Extension of the regular to be continued ....

Regular expressions in the shell

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.