var str = "Hello, my name is John";
var prefix = "my";
var suffix = "is";
var regExp = new RegExp(prefix + "(.*)" + suffix);
console.log(str.match(regExp)[1]); //name...
- 内容创作
AI正在思考,请稍等...
- 问题越精准、内容越详细,请勿提交相同标题!