These simple methods tell you either a match has been established or not.
The top 3 reappearance the location in the string of the match, or -1 if no match is found.
The test technique proceeds true or false. The string match technique in addition to the regular expression exec method deliver more particulars about search fallouts.
These are deliberated here.
Explanation and Procedure
This method is very easy because it will accept the single argument as well.
A design to search for in the string it is appealed on.
This argument could be a steady expression or else a string, which will routinely be changed to a consistent expression.
The search method is comparable to the indexOfand lastIndexOf approaches in that it yields the site of the first originated match, or -1 if it is not found.
We prove with a case- impervious search by means of the same string as displayed in examples below.
The search () method hunts a string for a stated value, and yields the position of the contest. The hunt value can be sequence or else a regular manifestation. This method will return -1 if no equal is originated.
It is a very simple syntax.
You can use it again and again in your code and make your website more efficient.
It is a string which will be converted into a regular expression easily.
Required is also considered as a regular expression.
The return value is just a number, which is used to represent the position of the specified searchvalue, or -1 if no match is found.
On the other hand, the JavScript version has a technical detail which is ECMA script 1.
Perform a case-sensitive search:
var str = "Mr. white has a white house"; var n = str.search("white");
Perform a case-insensitive search:
var str = "Mr. white has a white house"; var n = str.search(/white /i);