The following set of examples will help you understand the search Function.
The third statement looks for the index position of a substring “Script” and stores the index value in Str3. Remember, You should count the space as One Character.
For Str4, we are looking for a non-existing string “abc” inside Str1. Since the Search function doesn’t find the substring, it returns -1 as output.
Now, let us use the i regular expression along with string. This statement performs the case insensitive string search So, it returns the index position of the first occurrence, i.e., ABC.