Basic Learning of regular expression (1)

Source: Internet
Author: User

Today, we will record some basic knowledge about regulator for future use.
1. Some syntaxes to be remembered.
Character matching Syntax:
\ D matches the number '\ d' to 3, not C;

\ D match non-digit '\ d' match C, not match 3;

\ W matches any single character '\ W \ W' to match A3, not @ 3;

\ W match non-single character '\ W' match @, does not match C;

\ S matches blank characters '\ D \ s \ d' to match 3 D, not ABC;

\ S matches non-null characters '\ s \ s' to match a #4, not 3 D;

. Match any character '...' matches a $5, does not match line feed;

[…] Matching any character in the brackets [B-d] matches B, C, and D, but does not match E;

[^…] Match non-Parentheses [^ B-Z]: Match A. do not match B-Z;

Repeated matching Syntax:

{N} matched n characters \ D {3} matched \ D, not matched \ D or \ D

{N ,}match n times or more \ W {2} match \ W and \ W or above, not match \ W

{N, m} matches \ s, mismatch \ s

? Match 0 or 1 time 5? Match 5 or 0, not 5 or 0

+ Match one or more \ s + matches more than one \ s, and does not match more than one \ s

* Match 0 or more times \ W * match 0 or more \ W, not match non-N * \ W

Character locating Syntax:

^ Locate the start position of the subsequent mode

$ The front mode is at the end of the string

\ A Start position of the previous Mode

\ Z front mode end position

\ Z front mode end position (before line feed)

\ B matches a word boundary

\ B matches a non-word boundary

Escape matching Syntax:

"\" + Actual character \. * +? | () {}^ $ For example: \ matched character "\"

\ N match line feed

\ R match and press ENTER

\ T matches horizontal tabs

\ V matches vertical tabs

\ F match form feed

\ NNN matches an octal ASCII

\ Xnn matches a hexadecimal ASCII

\ Unnnn matches four hexadecimal uniode

\ C + uppercase letters match Ctrl-UPPERCASE letters, for example, \ CS-match Ctrl + S

The above are some regulator syntaxes that must be memorized.

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.