How can I include a dynamic variable into a regexp object?
var pattern:RegExp = new RegExp(/'a '/ + keyword, '/gi');
In this case, I'd like the regex to match "a bird", or "A biRD" (if 'bird' is the keyword). However, 'bird' should not match if it is on its own.
Furthermore, I have a follow up question (I hope it's not too much to ask!): How would I do the exact thing above, but in which the regex only matches if the keyword is NOT preceded by 'a ' (I believe this involves the use of the ^ or the !, but I can't seem to find any clear documentation in any language for my specific request).
In the case of my second question test cases would look like this:
WORKS
abird
bird
bbbbirdddd
DOESN'T WORK
a bird
a birdddd
Any help will be greatly appreciated!