Debugging JavaScript The problem encountered in the regular expression _javascript tips

Source: Internet
Author: User

About string test splitting in regular expressions. We generally have test () and Exec () Two methods, the difference between the two methods I do not elaborate here, mainly is the test () returns a Boolean value, EXEC () returns a matching array of characters, but today I encountered a problem, The program is very simple, but the problems in it makes me very difficult to find the answer on the internet did not find (personal comparison dish).

Copy Code code as follows:

var pattern=new RegExp ("Match", "IG");
Alert (Pattern.test ("Match"));
Alert (pattern.exec ("Match"));

The value of the first alert () is expected to be true

But the second test value was surprisingly null.

On this issue I do not know what the principle, because I did not see the function source code, if a friend can point out gratitude!!

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.