Javascript| Web Page |
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.
First, there are 2 ways to create regular expressions:
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.