JavaScript match() Method
JavaScript String Object
Definition and Usage
The match() method returns the matches when matching a string against a
regular expression.
This method returns an array of information, or null if no match is found.
Syntax
| stringObject.match(regexp) |
Example
Example
Perform a global, case-insensitive search for "ain":
<script type="text/javascript">
var str="The rain in SPAIN stays mainly in the plain";
var patt1=/ain/gi;
document.write(str.match(patt1));
</script>
|
The output of the code above will be:
Try it yourself »
|
JavaScript String Object
|