I'm currently generating a regex statement for a string comparing program I'm writing for my Discord bot. I am using the following generated regex string:
let regex = new RegExp("(TRIGGER WORD) (.*?)", "g");
I then execute it using the following:
let returns = regex.exec("TRIGGER WORD WHAT");
I get the following:
[ 'stud, ', 'stud,', '', index: 0, input: 'stud, what' ]
Which has no indication of grouping for 'WHAT' which I am trying to get most importantly.
From a background in PHP, I am expecting that I will get an array back such as the following:
['TRIGGER WORD', 'WHAT']