Shell Regular Expression

Source: Internet
Author: User
Tags character classes

Shell Common Regular Expressions

Common Regular expression ^        # line Header locates $       # end of row.       # match any character except line break *      # match 0 or more repeating characters +       # Repeat once or more?       # repeat 0 times or once?         # end the greedy factor. *? Represents a minimum match []      # matches any one of the characters in a set [^]      # Matches characters not in the specified group \      # used to escape metacharacters <      # Word-head Locators (Support VI and grep)  <love>      # Final Locator (Support VI and grep)  love>x\{m\}        # repeated occurrences m times x\{m,\}       # repeated occurrences at least m times x\{m,n\}      # repeats at least m times not more than n x?       # match occurs 0 times or once in uppercase letters xx+       # matches one or more letters X ()            # The characters within the parentheses for a set (Ab|de) +      # match a series of (at least one) ABC or DEF;ABC and Def will match [[: alpha:]]< c23/># stands for all letters regardless of the case [[: Lower:]    # = lowercase letters [[: Upper:]]    # means uppercase [[:d Igit:]] #    denotes numeric characters [[:d Igit:][:lower:]]    

Metacharacters

\d   # matches any one digit \d # matches any   single non-numeric character \w   # matches any single alphanumeric underscore character, synonym is [: alnum:]\w    # matches non-numeric characters

Character classes: whitespace characters

\s    # matches any whitespace    character \s # matches non-whitespace characters \b    # matches the beginning or end of a word \ n # matches a    newline character \ r    # matches a carriage return \ t    # match tab \b    # match backspace    # match a null value character

Character classes: Anchoring characters

\b    # Match word boundary (not in []) \b    # matches non-word boundary \a    # Match string beginning \z    # Match string or end of line \z    # Match string only end \g    # Match Previous m// g Where to leave

 Capture

(exp)                # match Exp, and capture text into the automatically named group (? <name>exp)         # Match exp, and capture the text to a group named name, you can also write (? ' Name ' Exp ' (?: exp)              # matches exp, does not capture matched text, and does not assign group numbers to this group

0 Wide Assertion

(? =exp)              # match exp front position (? <=exp)             # Match exp back to position (?! EXP)              # match the position followed by the exp (? <!exp)             # match the location (? #comment) that is not in front of exp (?) # Comments do not         have any effect on the processing of regular expressions for commenting

 Special characters

Http://en.wikipedia.org/wiki/ascii_table^h  \010 \b  ^m  \015 \ R matches special characters: Ctrl + V CTRL does not press H or M to output ^h for matching

  

Shell Regular Expression

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.