About regular Expressions

Source: Internet
Author: User

Regular is to deal with strings, using regular and convenient, and high performance

Define VAR reg=new RegExp (Rules, Options);//option can have no

Abbreviated VAR reg=/rules/options;

Options:

I ignore case

G looking from beginning to end

M Multi-line

Escaped: with \

\d represents a number

\w words

\s spaces

\d Non-digital

\w Non-word

\s Non-whitespace

Method:

Str.search (Regular) Look for no return-1

Str.math (regular) matches out, returns the object (array), if no match to the result returns null

Str.replace (Regular, WHO) represents the replacement

Quantifier: Specify several

{n} exactly n

{n,m} at least n max of M

{N,} at least N, up to an unlimited number of

? Dispensable

+ Several

* Can not, have an unlimited

Note: quantifiers just before one

Modified:

^ Beginning of the line

+ End of Line

\d Boundary

Note: ^ If no mate M is used, it refers to the beginning of the entire string
^ string wrapping is automatically recognized if mated with M

Square brackets ""

1 any A or B or C in "abc" ""

2 "0-9" This is the expression of an interval

3 "^ABC" excludes any other than a B C

Attention:

1^ $ to be higher than | priority

2 Do you implement a trim function? It means filtering the leading and trailing spaces

About regular Expressions

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.