Java脚本:替换两个变量之间的字符串

时间:2018-01-30 11:42:35

标签: javascript

我需要在两个变量之间替换字符串,如下所示:

var str_before    = 'I Love My Cat So Much';
var start_mark    = 'My';
var end_mark      = 'So';
var str_replace   = 'Pussy Cat Very';

// Maybe

var after_replace = str_before.replace(start_mark, end_mark, str_replace);
// Replace String Between 'My' And 'So' With 'Pussy Cat Very'
// I Love Pussy Cat Very Much

0 个答案:

没有答案