Search a string for the character "e":
Since there is an "e" in the string, the result of res will be:
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.
The exec() method is supported in all major browsers.
Parameter | Description |
---|---|
string | Required. The string to be searched |
Type | Description |
---|---|
Array | An array containing the matched text if it finds a match, otherwise it returns null |
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: