The search() method is represented by the following syntax:
regexp - It represents the regular expression which is to be searched.
The position of searched character.
Let's see some examples of search() method.
Let's see a simple example to search for a string.Test it Now
In this example, we will see that search() method is case-sensitive.Test it Now
We can ignore case-sensitive behaviour of search() method by using ignore flag. Let's understand with the help of example:Test it Now
In this example, we will search a regular expression which is not present in the given string.Test it Now