Home > Web Front-end > JS Tutorial > body text

The difference between indexof and search methods based on js string (graphic tutorial)

亚连
Release: 2018-05-19 09:18:11
Original
1600 people have browsed it

Below I will share with you an introduction to the differences between the JS string indexof and search methods. It has a good reference value and I hope it will be helpful to everyone.

1.indexof method

indexOf() method can return the position where a specified string value first appears in the string.

Syntax:

Note: There are optional parameters (that is, setting the starting search position) .

2. Search method

The search() method is used to retrieve the specified substring in the string, or search with a regular expression matching substring.

Note: The search method can search for the specified string based on a regular expression (can ignore case, and does not perform a global search), At the same time, there are no optional parameters (that is, setting the starting search position).

The above is what I compiled for everyone. I hope it will be helpful to everyone in the future.

Related articles:

Detailed explanation of JS cross-domain POST implementation steps

Summary of JS operation DOM tree traversal method

JS gets the least common multiple and the greatest common divisor

The above is the detailed content of The difference between indexof and search methods based on js string (graphic tutorial). For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template