Search a string for the character "e":
Since there is an "e" in the string, the result of res will be:
The test() method tests for a match in a string.
This method returns true if it finds a match, otherwise it returns false.
The test() method is supported in all major browsers.
Parameter | Description |
---|---|
string | Required. The string to be searched |
Type | Description |
---|---|
Boolean | Returns true if it finds a match, otherwise it returns false |
JavaScript Version: | 1.2 |
---|
Do a global search, and test for "Hello" and "W3Schools" in a string:
The output of the code above will be: