Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to use split method to intercept string in js

Shulou Source: shulou.com Published: 2022-05-31 10:38:21 10月26日 Update

This article mainly explains "how to intercept strings with split method in js". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn "how to intercept strings with the split method in js".

1. Split () method

Is a string method that can cut strings into arrays.

2. Grammar

StringObject.split (separator,howmany)

3. Parameters

Separator (required): is a string or regular expression that splits the stringObject from the place specified by this parameter.

Howmany (optional): this parameter specifies the length of the returned array.

Note: if howmany is set, no more substrings will be returned than the array specified by this parameter. If howmany is not set, the entire string will be split, regardless of its length.

4. Return value

An array of strings.

5. Examples

Example: str= "2018.12"; arr=str.split ("."); / / arr is an array containing "2018" and "12", and arr [0] is 2018 Magi Arr [1] is 12. At this point, I believe you have a deeper understanding of "how to intercept strings with the split method in js". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Tags: Characters strings methods arrays parameters content length learning utility depth examples interests places examples practicality practicality simplicity of operation more friends rules Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Apple Huawei macOS vpn NVidia