var a = "hello world, learn js"; var b = "hello"; a.replace(/hello/gim, "hi"));
var b = 'hello|learn'; a.replace(RegExp(b, 'gim'), 'hi');