JavaScript String search() method

The JavaScript string search() method determines a specified regular expression in a given string and returns its position if a match occurs. Syntax: string.search(regexp) Parameters: regexp: It represents the regular expression to be searched. Return: It will return the position of the regular expression if it is present in the string otherwise returns -1. Example: … Read more