TypeScript | String search() Method
The search() is an inbuilt function in TypeScript that is used to search for a match between a regular expression and this String object.
Parameter: This methods accept a single parameter as mentioned above and described below:
- regexp: This parameter is a RegExp object.
Return Value: This method returns the index of the regular expression inside the string. Otherwise, it returns -1.
Below example illustrate the String search() method in TypeScriptJS: