var alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
如何删除H
和S
之间的所有内容,以便结果为ABCDEFGHSTUVWXYZ
?
答案 0 :(得分:44)
var alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
alphabet = alphabet.replace(/H.*S/, 'HS')
或者只是:
var alphabet = "ABCDEFGHSTUVWXYZ";
答案 1 :(得分:9)
var strippedAlphabet = alphabet.replace(/H.*S/, 'HS');