In JavaScript, there are two ways to use regular methods, one is to create an instance of a regular expression, but rather to use a regular expression in a string object to relate the method.
Regular Expression Object
Two methods of creating
var my_regex=/[a-z]+/g;
var my_regex=new ("[a-z]+", "G");
Method
EXEC (string), which is regular processing of a string and returns the result of the match.
Test (string), which tests whether a string contains a matching result
Regular in a String object
Method
Match (pattern) is a regular match based on pattern and, if matched to, returns a matching result, such as a match that does not return null
Search (pattern) is a regular match according to pattern, if the match to a result, then return its index number; otherwise return-1
Replace (pattern,replacement) is a regular match based on pattern, and the matching result is replaced by replacement
Split (pattern) is a regular segment based on pattern, which returns a segmented array.
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.