JavaScript RegExp Object
The test() method tests for a match in a string.
This method returns true if it finds a match, otherwise it returns false.
| Parameter | Description |
|---|---|
| string | Required. The string to be searched |
![]()
The test() 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.