Regular Expression, Regular Expression

Source: Internet
Author: User

Regular Expression, Regular Expression

Basic Regular Expression

First line positioning character ^

Ls | grep ^ files starting with abc


Line tail locator $


Match a single character.

. Represents any character, except for line breaks


Qualifier *

* Represents the first 0-n characters


Character Set matching []

[Abc] indicates that a character is a, B, or c.


Character Set mismatch [^]

[^ Abc] indicates a character not a, B, or c.


Expanded Regular Expression

Qualifier +

The first 1-n characters, a + indicates that there are 1 to n


Qualifier?

The first 0-1 Characters


Vertical bars | and parentheses ()

(Abc | def | ghi) indicates that the value is abc, def, or ghi.


Number of matches {m, n}

(Abc) [1, 2] indicates abc or abcabc


Perl expressions

Number match \ d

Equivalent to [0-9]


Non-digit match \ D

Equivalent to [^ 0-9]


Blank character match \ s

Equivalent to [\ f \ n \ r \ t \ v]


Non-blank character match \ s

Equivalent to [^ \ f \ n \ r \ t \ v]


Example

Start with abc and end with xyz: ^ abc. * xyz $

Not starting with abc:

Does not contain abc:

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.