how can I use a variable in match() if I want to use regex? This works fine for me:
if (message.match('!' + cmd)) {
this.client.say(to, myJson[cmd]);
}
but if I try something like this it will not check the variable.
if (message.match(/!cmd/i)) {
this.client.say(to, myJson[cmd]);
}
I already searched for a solution but could only find something for replace.
Edit: it's not a duplicate of How do you use a variable in a regular expression? as it explains it for replace not match.