JS Regular expression

Source: Internet
Author: User

Regular expressions

1. mode

/reg/i Ignore Case

/reg/g, Get all

/reg/m, can put \ n as multiple lines

2. Brackets

[] or

[^] except

lin[^ux]x; can match to Lin X , meaning that the spaces here are contained in [^ux] in

3. parentheses

() delineation range

Backward reference

$ , A string that represents the first parenthesis in a match

4. Meta- characters

. any character except for the line break

\w a character that represents any number of letters and underscores [a-za-z0-9_]

\w represents other characters except for numeric letters and underscores [^a-za-z0-9_]

\d Find Numbers [0-9]

\d find non-numeric characters [^0-9]

\s Find white space characters   []

\s find non-whitespace characters   [^]

\ n Find line breaks  

\b represents the word boundary, which must be space on both sides of the word /\bp.p\b/ig

\b represents a non-word boundary

\xxx octal

\XDD hexadecimal

\uxxx Chinese Code

5. quantifiers

? 1 one or 0 a {0,1}

+1 one or more {1,}

* 0 a 1 one or more {0,}

.* blur matches multiple characters

.*? Exact Match

{n} n

{1,n} 1 to the N a

End   $

beginning   ^

(? =n) match the subsequent existence N part of

(!? =n) above counter-


This article is from the "rcid" blog, make sure to keep this source http://13419255.blog.51cto.com/13409255/1975760

JS Regular expression

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.