exec (JavaScript)
Executes a search using a regular expression.
Parameters |
Description |
searchString |
The string to be searched. |
Return value |
Description |
string[] |
Substrings that match the regular expression,
or null if the search fails. |
Usage
This RegExp
object defines
the search criteria.
Examples
This example returns
Moscow
- Moscow
.
var cities = new String("Paris Moscow Tokyo");
var regexp = /(Moscow)/;
var s = regexp.exec(cities);
if(s == null)
return "No match";
else
return s.join(" - ")
Have feedback?
Google Analytics is used to store comments and ratings. To provide a comment or rating for a topic, click Accept All Cookies or Allow All in Cookie Preferences in the footer of this page.