Syntax regexp.exec(string) The exec() method of the RegExp object executes the search for a match in a specified string.The results are returned in an array.The string passed contains the string the regular expression is trying to match in.