Use of the Javascript Regular Expression Test

Source: Internet
Author: User
<Script language = "JavaScript">
Function checkstr (s )...{
VaR regu =/ABC/GI;
VaR Re = new Regexp (regu );
Return re. test (s );
}
Checkmobile ('vpateabc ');
</SCRIPT>

Purpose: Check whether the input string contains ABC. If yes, true is returned. Otherwise, false is returned.
Method
Test (string): test whether the string contains matching results.

Regular Expressions in string objects
Method
Match (pattern): regular match is performed based on pattern. If it matches, the matching result is returned. If it does not match, null is returned.
Search (pattern): regular match is performed based on pattern. If a result is matched, the number of indexes is returned; otherwise,-1 is returned.
Replace (pattern, replacement): Perform regular match based on pattern and replace the matching result with replacement.
Split (pattern): Regular segmentation based on pattern, returns a split Array

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.