JS (JavaScript) Regular Expressions (Summary)

Source: Internet
Author: User

Regular Expressions are powerful.

The regular expressions in each language are similar. Learn one, and others are quick to learn,

JS Regular Expression highlights blog:

1 JavaScript Regexp Object Reference Manual W3C http://www.w3school.com.cn/js/jsref_obj_regexp.asp

2 JavaScript http://www.yaosansi.com/post/745.html using regular expressions

Regular Expression http://www.iteye.com/topic/30728 of 3 JS

4 JavaScript classic Regular Expression http://www.dedecms.com/html/xitongyanshi/20070423/38637.html

5 warm New Javascript Regular Expression http://www.cnblogs.com/libinqq/archive/2008/07/31/1257699.html

Advanced JS replacement function

Simply replace the string, for example

Note that num = 2, num = 3, num = 1. How do we replace the number following num =?

VaR RegEx =/\ ] + num = (\ D) [^>] * \/\>/g; // extract . The write is complicated. You can extract the numbers after num =.

VaR result = "";
VaR DATA = "the above string ";
VaR I = 1;
Result = data. Replace (RegEx, function (smatch) {// smatch is the one extracted each time
Return smatch. Replace (/num = \ D/, "num =" + I ++ );
});
Alert (result );

Related Article

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.