This question already has answers here:
Regular expression to get a string between two strings in Javascript

(13个回答)


2年前关闭。



var alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

如何删除HS之间的所有内容,以便结果为ABCDEFGHSTUVWXYZ

最佳答案

var alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
alphabet = alphabet.replace(/H.*S/, 'HS')

要不就:
var alphabet = "ABCDEFGHSTUVWXYZ";

关于javascript - 替换/删除两个字符之间的所有内容,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/10689784/

10-09 14:51