jQuery删除所有的东西,包括某些字符 [英] jquery remove everything after and including certain character

查看:79
本文介绍了jQuery删除所有的东西,包括某些字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个要显示为Pearl River, NY的位置-Pearl River, NY (10965)(因此它必须删除(10965)-包括(之前的空格-我不打算为此做很多事情并在服务器端执行任何操作.jQuery可以正常工作.我知道这很简单,我只是不经常使用JS.

I have a location - Pearl River, NY (10965) that I want displayed as Pearl River, NY (so it must delete (10965) -- including the space before ( -- I'm not looking to make a big deal of this and do anything server side. jQuery would work fine. I know this is probably simple as hell, I just don't use JS much.

谢谢!

推荐答案

location_string = location_string.replace(/ \([^)]*\)/, '');

另一方面,请不要再认为jQuery对于所有内容都是必需的,尤其是不需要像这样的字符串操作任务.确实不是,并且jQuery被夸大了.

On a side note, please stop thinking that jQuery is necessary for anything at all, especially not a string manipulation task like this. It really isn't, and jQuery is overhyped.

这篇关于jQuery删除所有的东西,包括某些字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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