English [sɜ:tʃ] US [sɜ:rtʃ]

##v. Search; search, search; investigate; explore

n. Search; investigate; explore

Third person singular: search Present participle: searching Past tense: search Past participle: search

javascript search() method syntax

Function:Used to retrieve a specified substring in a string, or retrieve a substring that matches a regular expression.

Syntax:stringObject.search(regexp)

Parameter:regexp This parameter can It is the substring that needs to be retrieved in stringObject, or it can be the RegExp object that needs to be retrieved. Note: To perform a case-ignoring search, append the flag i.

Returns: The starting position of the first substring matching regexp instringObject.

Note:The search() method does not perform a global match, it will ignore the flag g. It also ignores the lastIndex property of the regexp and always retrieves from the beginning of the string, which means it always returns the first matching position of the stringObject.

Comments:If no matching substring is found, -1 is returned.

javascript search() method example

    Title 

Run instance »

Click the "Run instance" button to view the online instance