Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How does js intercept all the characters after a string

Shulou Source: shulou.com Published: 2022-05-31 10:38:46 09月23日 Update

This article mainly introduces the relevant knowledge of how js intercepts all the characters behind the string, the content is detailed and easy to understand, the operation is simple and fast, and it has a certain reference value. I believe you will gain something after reading this js article on how to intercept all the characters behind the string. Let's take a look.

1. Use the split () method

Split a string into an array of strings

Var str = str.split ("") var targetStr = str.length-1]

2. Use the substr () method

You can extract a specified number of characters from a string starting with the start subscript.

Str.substr (str.length-1,1)

3. Use the charAt () method

Characters that can return to a specified position

Str.substr (str.length-1,1)

4. Use the regular method

Var s = "ysahdu"; s.replace (/ ^ (. * [n]) *. * (. | n) $/ g, "$2"). This is the end of the article on "how js intercepts all the characters after a string". Thank you for reading! I believe you all have a certain understanding of "how js intercepts all the characters behind the string". If you want to learn more, you are welcome to follow the industry information channel.

Tags: Character string method knowledge content article subscript value location available in easy to operate array article easy to understand more regular purpose look industry information Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MariaDB Shulou Technology Shulou Tech Info Microsoft NVidia