CopyCodeThe Code is as follows: var STR = "abcdefghijklnabcdefghijklmnabcabdefghijklmn ";
Re =/A/g;
Alert (Re. Test (STR ));
// If the test method is called, true or false is returned, indicating whether a matched character is found in the specified string. -- true
Alert(re.exe C (STR ));
// Returns the first string matching the expression in the string --
Alert (Str. Match (re ));
// Returns an array. Each item matches the expression array --- [a, a, a] note that g global variables must be used for regular expressions.
Alert (Str. Search (re ))
// Returns the position of the matched Regular Expression starting from 0 for the first time. The returned result is-1 -- 0 * a bit like indexof *
Alert (Str. Replace (Re, "B "))
// Replace. Needless to say *
Alert (Str. Split (re) [0])
// Split is generally used to divide a string into array objects and return the value of 0 in the array.
Regular Expressions can simplify many operations. Especially for form data verification.