删除Javascript中的部分字符串 [英] Remove portion of string in Javascript

查看:60
本文介绍了删除Javascript中的部分字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Javascript中有一个像这样的字符串:

I have a String like this in Javascript:

string = '@usernameWhats on your mind?'

我需要从字符串中删除'Whats on your mind?'.

I need to get rid of 'Whats on your mind?' from the string.

我该怎么做?

推荐答案

var new_string = string.replace('Whats on your mind?', '');

这篇关于删除Javascript中的部分字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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