August 1999
Intermediate to advanced
1488 pages
72h 53m
English
string.search(regexpression)
The search() method of an instance of the String object searches the string in which it is invoked for the regular expression passed to the method. The regular expression is made up of a pattern and flags that dictate what is to be matched. The method returns the indexed start location of the string if it is found and –1 if the string does not contain a regular expression match.
Tip
See the reference entry for RegExp for a list of the patterns and flags that can be used to create a regular expression.
Listing 6.248 creates an instance of the String object, which is searched for the first instance of a space. If a ...
Read now
Unlock full access