gpt4 book ai didi

jquery - jQuery 中的 RTrim

转载 作者:IT王子 更新时间:2023-10-29 03:09:15 24 4
gpt4 key购买 nike

我在使用 jQuery 的 trim 时遇到了问题。我在 jQuery 中有一个这样的字符串:

var string1;
string1 = "one~two~";

如何修剪结尾的波浪号?

最佳答案

.trim() jQuery 的方法引用空格..

Description: Remove the whitespace from the beginning and end of a string.


你需要

string1.replace(/~+$/,'');

这将删除所有尾随 ~

所以 one~two~~~~~ 也会变成 one~two

关于jquery - jQuery 中的 RTrim,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8791394/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com