"Mastering Regular Expressions" Read Note 001

Source: Internet
Author: User

. Match any character except newline characters ( as a matching target when used in [] .)

^ start of matching string : ^cat matches cat,catd.

$ Match end of string : $cat match cat,dddCat

? repeat 0 or one time ( acts only on the front adjacent element ). Colou?r Match Color,colour Col (OU)? r Match Colr,colour

+ Repeat 1 or more times

* Repeat 0 or more times

[] matches any one of the characters in parentheses : c[ae]t matches Cat,cet,ccatd,cetdd,aacat.

- represents a range ( only used in [] , otherwise as a matching target ):[0-9], Match any one number .

^ ( when used in [] ) matches characters not in brackets:t[^2-6] matches t1,t7,t9t, does not match t2,t6d,t34d,123t,t1

A|b match a or b:aa|cc match : aa,cc; (A|CD) 3 matches : 12a3, 12CD3

\< match start ; \> match End

{N,m} Match Duplicates N to the m:ta{1,4}d Match Tad,taad,taaad,taaaad

match the hour of the year

([01]? [0-9]|2[0-4]): [0-5][0-9]

([01]? [4-9]| [012]? [0-3]): [0-5][0-9]

(?:  

) to look around (from left to right to see the text) to indicate   get the front position of the match, such as   get ' ab ' where it appears: Match   match   TADC&NBSP; a (? =ad)   match &NBSP, TAADC&NBSP; TADC

(? <= ...   Positive Reverse view (right-to-left viewing text) indicates the post-location of the matched content, such as (? <= AD); get where ' ab ' appears: Match tad_bc (' _ ' does not exist in the word, it represents the location of the match )

(?! ... ) Negative order Surround

(? <! ... ) negative reverse-order surround

\ t tab

\s Blank

\s any characters except whitespace characters

\w = = [A-za-z0-9]

\w ==[^a-za-z0-9]

\d = = [0-9]

\d ==[^0-9]

"\b" matches the word boundary ( with \s,\n,\t, comma , period as the boundary ) and does not match any characters. The match is just a position where the side of the position is the character that makes up the word, the other side is a non-word character, the start or end position of the string. "\b" is 0 width.

//===============================================///////

Modifier

In an expression, such as /a[0-9]/i is a modifier, which indicates that the match ignores case

G Global Match

x loose arrangement

"Mastering Regular Expressions" Read Note 001

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.