Home >Web Front-end >JS Tutorial >JavaScript method to remove symbols at the end of spliced ​​strings

JavaScript method to remove symbols at the end of spliced ​​strings

青灯夜游
青灯夜游forward
2021-01-13 18:48:263008browse

JavaScript method to remove symbols at the end of spliced ​​strings

Preface: In JS, sometimes it is necessary to splice strings, and the spliced ​​strings are separated by certain symbols. At the end of the spliced ​​string There will be one more delimiter. In this case, we can use the following methods to remove the delimiter at the end.

For more programming-related knowledge, please visit: Programming Learning! !

Method 1: Use substring() and lastIndexOf()

Method 2: Use substring() and length Attribute

Method 3: Use regular expression

For more programming-related knowledge, please visit: Programming Learning! !

The above is the detailed content of JavaScript method to remove symbols at the end of spliced ​​strings. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:cnblogs.com. If there is any infringement, please contact admin@php.cn delete