Alert (r); if (r! = null) Alert (R! = null) Alert ("THE REGAL's INPUT IS: R.Input); if (r! = null) Alert "The regular's index is:" r.index); if (r! = null) Alert ("The Regular's LastIndex IS:" R.lastIndex); Return (R); // Return the first appearance "ain" The place. } function matchdemo_ig () {var r, re; // declared variable. // var s = "the rain in spain falls mainly in the place"; re = / ain / ig; // Create a regular expression mode. R = s.match (re); // Try to match the search string. Alert (r); if (r! = null) Alert (R! = null) Alert ("THE REGAL's INPUT IS: R.Input); if (r! = null) Alert "The regular's index is:" r.index); if (r! = null) Alert ("The Regular's LastIndex IS:" R.lastIndex); Return (R); // Return the first appearance "ain" The place.
} Function ReplaceStr () {var RE = / ain /; s = s.Replace (Re, "Test"); Alert ("THE STRING CHANGE TO:" S);} Function ReplaceStr_i () {var RE = / ain / i; s = s.Replace (Re, "test"); Alert ("THE STRING CHANGE TO:" S);} Function ReplaceSTR_G () {var RE = / ain / g; s = s.replace (Re , "Test"); Alert ("Test" s);} Function ReplaceStr_ig () {var RE = / AIN / IG; S = S.Replace (RE, "Test"); Alert ("THE String change to: " s);} // -> script> string: the rain in spain Falls Mainly in the plain
body> html> description
If the Match method does not find a match, return null. If you find a match to return an array and update the properties of the global REGEXP object to reflect the matching result.
The array returned by the Match method has three properties: INPUT, INDEX, and LastIndex. The Input property contains the entire lookup string. The Index property contains the location of the sub-string that matches throughout the lookup string. The LastIndex property contains the next location of the last character in the last match. If the global flag (G) is not set, the 0 element of the array contains the entire match, and the first to n elements contain any of the matches that have appeared in the match. This is equivalent to the EXEC method that does not set global logo. If the global flag is set, the elements 0 to n include all matching.