JavaScript RegExp Object
The exec() method tests for a match in a string.
This method returns the matched text if it finds a match, otherwise it returns null.
| Parameter | Description |
|---|---|
| string | Required. The string to be searched |
![]()
The exec() method is supported in all major browsers.
Do a global search, and test for "Hello" and "W3Schools" in a string:
The output of the code above will be:
JavaScript RegExp Object
Your message has been sent to W3Schools.