EXEC: Regular processing of string and return of matching result. Array[0] is the original string, Array[i] to match the position in the entire searched string.
Test: Tests whether string contains a matching result, contains return true, and does not contain return false.
Match (pattern): 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): a regular match based on pattern and, if matched to a result, returns the number of its indexes; otherwise, return-1
Replace (pattern,replacement): a regular match based on pattern, which replaces the matching result with a replacement
Split (pattern): Regular segmentation based on pattern, returning an array of partitions
Instance:
Copy Code code as follows:
function Checkform () {
var u = document.form_name.check.value;
var s =/^[-a-za-z0-9_]+ (\.[ -a-za-z0-9_]+) *@[-a-za-z0-9_]+ (\.[ -a-za-z0-9_]+) *$/;
var a = s.exec (u);
var a = s.test (u);
var a = U.match (s);
var a = U.search (s);
alert (a);
}
Replace
The simplest kind of ability is the simple character substitution. The sample code is as follows:
Copy Code code as follows:
var U = "JavaScript is a good script language";
Here I want to replace the letter A with the letter A
var s =/a/g;
var a = U.replace (S, "a");
</script>
Split
Copy Code code as follows:
<script type= "Text/javascript" >
var str= "How are your doing today?"
document.write (Str.split ("") + "<br/>")
document.write (Str.split ("") + "<br/>")
document.write (Str.split ("", 3))
</script>
The output results are:
How,are,you,doing,today?
H,o,w, A,r,e, Y,o,u, D,o,i,n,g, T,o,d,a,y,?
How,are,you