Description
The match() method searches for a match between a regular expression and a string, and returns the matches.
This method has the form:
String.match(regexp)
Parameter | Description |
---|---|
regexp | (required) A regular expression |
Examples
The following example shows the basic use of this method.
<script>
var s = "The rain in SPAIN stays mainly in the plain";
var pat = "/ain/gi";
document.write(s.match(pat));
</script>
This produces the following result:
Browser Support
Firefox | IE | Chrome | Opera | Safari |
---|---|---|---|---|