I'm trying to pass a variable to my javascript regular expression, but it returns null all the time. Regular expression is correct, but, Im unable to execute it on the JS. Below is my code:
'use strict';
function matchExp(val) {
let text = 'Is this " all": there is?';
var match_pat = '[^"]* all\b[^"]*("\s*:)'
var regMatch = new RegExp(match_pat, 'g');
return(text.match(regMatch))
}
console.log(matchExp())
module.exports = {
matchExp
}
**Expected Result**: "all":