我有很多文字:
var one = 'this_is_first_text#test=4';
var two = 'second_text#test=2';
var three = 'next_text#test=243';
var four = 'last_text_for_this#test=44';
如何删除 #test = X ?
我只能删除文字:
one.replace('#test=', '');
但要删除数字很热吗?
答案 0 :(得分:4)
one = one.slice(0, one.indexOf('#'));
答案 1 :(得分:3)
答案 2 :(得分:3)
one = one.split("#"); one=one[0];
答案 3 :(得分:1)
使用正则表达式?
one.replace(/\#test\=.*/,'');