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

Usage and definition of js split js split split string into array example code_Basic knowledge

WBOY
Release: 2016-05-16 17:53:43
Original
1265 people have browsed it

There is not much else to say about the usage of js split. Let me give you an example directly below. >




The output result is
2
2
3
5
6
6
js split is to split a string into multiple strings with specific characters. You should You'll understand it at a glance.

The following is the official reference for the definition and usage of js split.

Definition and usage
The split() method is used to split a string into a string array.

Syntax
stringObject.split(separator,howmany)

Parameter Description
separator Required. A string or regular expression to split the stringObject from where specified by this parameter.
howmany optional. This parameter specifies the maximum length of the returned array. If this parameter is set, no more substrings will be returned than the array specified by this parameter. If this parameter is not set, the entire string will be split regardless of its length.


Return value
A string array. The array is created by splitting the string stringObject into substrings at the boundaries specified by separator. The strings in the returned array do not include the separator itself.

However, if separator is a regular expression containing subexpressions, then the returned array includes strings matching those subexpressions (but not text matching the entire regular expression).
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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!