Gets substrings that match a regular expression.
| Parameters | Description |
|---|---|
| regExp | A regular expression. This can be a literal or a RegExp object. |
| Return value | Description |
|---|---|
| string[] | The matching string or strings. |
var cities = new String("Paris Moscow Tokyo");
var regexp = /(Moscow)/;
var a = cities.match(regexp);
if(a == null)
return "No match";
else
return a[0];
(2) This example finds a regular expression object.
var cities = new String("Paris Moscow Tokyo");
var regexp = new RegExp("(moscow)", "i");
var a = cities.match(regexp);
if(a == null)
return "No match";
else
return a[0];