In JavaScript, the search() method is used to retrieve a specified substring in a string, or to retrieve a substring that matches a regular expression, and returns the position of the first occurrence of the substring. The syntax "string .search(searchvalue)"; if no matching substring is found, "-1" is returned.
The operating environment of this tutorial: windows7 system, javascript version 1.8.5, Dell G3 computer.
javascript search() method--search string
The search() method is used to retrieve the specified substring in the string, Or retrieve a substring that matches a regular expression.
Syntax:
string.search(searchvalue)
Parameter description:
Return value:
Example:
Perform a case-sensitive search## Perform a case-ignoring search
[Related recommendations:
javascript learning tutorialThe above is the detailed content of How to use search() in javascript. For more information, please follow other related articles on the PHP Chinese website!