在javascript中的RTrim [英] RTrim in javascript

查看:99
本文介绍了在javascript中的RTrim的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了jQuery修剪的问题。我在jQuery中有一个字符串:

I am having a problem with jQuery's trim. I have a string such at in jQuery:

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

如何修剪尾随波浪号?

How do I trim the trailing tilde?

推荐答案

.trim() jQuery的方法是指空格..

The .trim() method of jQuery refers to whitespace ..


说明:从字符串的开头和结尾删除空格。

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






你需要


You need

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

这将删除所有尾随

所以一个〜两个~~~~~ 也会变成一个〜两个

这篇关于在javascript中的RTrim的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆