Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to use substr to intercept strings in javascript language

Shulou Source: shulou.com Published: 2022-05-31 10:50:28 09月25日 Update

Most people do not understand the knowledge points of this article "how to intercept strings with substr in javascript language", so the editor summarizes the following contents, detailed contents, clear steps, and certain reference value. I hope you can get something after reading this article. Let's take a look at this article "how to intercept strings with substr in javascript language".

Description

1. Extract a specified number of characters from the string starting with the start subscript.

2. The string of specified length (N2) is intercepted from the specified position (N1). The second parameter is to intercept several strings.

Grammar

StringObject.substr (start,length)

Return value

Returns a new string.

Example

Let str = 'abcde';let re = str.slice (1, 3); / / output: bc// is truncated from index value 1 to 3, but note that the character in the end position cannot be taken, and the previous let re = str.substring (1) can be obtained. / / output: bcde// is intercepted from index value 1 to the end. Note that the character at the end position cannot be obtained. If there is only one parameter, it will be taken all the way from this index value position to the last let re = str.substr (1,3); / / output: bcd// will be intercepted from index value 1 and intercept 3. Note that if there is only one parameter, then intercept to the last console.log (re). The above is about the content of this article on "how to intercept strings with substr in javascript language". I believe we all have some understanding. I hope the content shared by the editor will be helpful to you. If you want to know more about the relevant knowledge, please follow the industry information channel.

Tags: Character string content location index language parameter output only article knowledge article subscript value most examples that is meaning more steps Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno vpn Redmi Linux NVidia Xiaomi