match (RegExp - JavaScript)

Gets substrings that match a regular expression.

Defined in

RegExp (Standard - JavaScript)

Syntax

match(searchString:string) : string[]

Parameters Description
searchString The string to be searched.
Return value Description
string[] The matching string or strings.

Usage

This RegExp object defines the search criteria.

If the search string does not contain the substring that matches the regular expression, the return value is null.

Examples

This example finds a regular expression literal.
var cities = new String("Paris   Moscow   Tokyo");
var regexp = /(Moscow)/;
var a = regexp.match(cities);
if(a == null)
	return "No match";
else
	return a[0];