match js
// The match() method searches a string for a match against a regular expression,
// and returns the matches, as an Array object.
// If the regular expression does not include the g modifier (to perform a global search),
// the match() method will return only the first match in the string.
// This method returns null if no match is found.
let str = "The rain in SPAIN stays mainly in the plain";
let res1 = str.match(/ain/g); /* ["ain", "ain", "ain"] */
let res2 = str.match(/ain/); /* ["ain", index: 5, input: "The rain in SPAIN stays mainly in the plain", groups: undefined] */
let res3 = str.match(/blah/); /* null */