【发布时间】:2019-12-26 11:36:49
【问题描述】:
我实际上是 JavaScript 新手。我目前正在研究字符串匹配。我可以理解为什么它可以使用等等,但是每当我试图使其动态化时,由于某种原因,我的输出为“null”。
function matchString(str, match) {
let result = str.match('/' + match + '/g');
console.log('Output: ' + result);
}
matchString('Hello Stack Overflow', 'over'); // 空
function matchString(str, match, para) {
let result = str.match('/' + match + '/' + para);
console.log('Output: ' + result);
}
matchString('Hello Stack Overflow', 'over', 'g'); // 空
我希望它在我的控制台中输出“结束”
【问题讨论】:
标签: javascript