JavaScript Regular Expressions

Source: Internet
Author: User

(1)
String Lookup:
Search (' a ');//Find location
SUBSTRING (starting point, end point);//not including the end position
Chartat (3);//Take Out third place
Split ('-')//by-slicing
Match ();//Put all matching, all up.
replace;//replaces all matches, returns the replaced string
(2)
RegExp Object
JS Style: var re = new RegExp (a);
Prel style: var re =/a/;
(3)
Ignore case: i/a/i
Global match: G/\d/g
^ Beginning of the line
$ End of line
^$
Quantifiers:
Several: +/\d+/
{n}: occurs exactly n times
{n,m}: At least n times, up to M times
{N,}: At least n times, Maximum unlimited
?: {0,1}
*:{0,}
(4)
Escape:
\d: Digital
.: arbitrary string
\w: English, numerals, underline
\s: whitespace characters
\d: Non-digital
\w: Non-English, numerals, underline
\s: Non-blank
Metacharacters
[abc]//from ABC to pick a
[0-9]//0 to 9
[^a-z]//except A to Z
Verify Mailbox
Re = ^/\w+ @ [0-9a-z]+ \. [a-z]+/i$
Re.test (str), or//a part that meets the requirements returns true, non-conforming returns false,

JavaScript 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.