JavaScript match() Method
Complete RegExp Object Reference
Definition and Usage
The match() method is used to search a string for a specified value.
The match() method returns an array of the matches found. If no match was found it returns
null.
This method supports regular expressions.
Syntax
stringObject.match(regexp)
|
Parameter |
Description |
regexp |
Required. A regular expression. |
Tips and Notes
Note: The match() method is case sensitive!
Example
In the following example we will search for "ain":
<script type="text/javascript">
var str = "The rain in Spain stays mainly in the plain";
var patt1 = /ain/g;
document.write(str.match(patt1));
</script>
|
Try-It-Yourself Demos
match()
How to use match() to search within a string using a regular expression.
Complete RegExp Object Reference
|
|
|
See why there are 20,000+ Ektron integrations worldwide.
Request an INSTANT DEMO or download a FREE TRIAL today. |
|
|
|