I am pretty new to Regex and what I want to do is the following.
Say I have a keyword array:
// the kwd is changed dynamically
var kwd = ["key1", "key2", "key3", "key4"];
I need to build a Regex to test if a string contains any of the keywords in that array. I wonder how can I generate that Regex expression dynamically?
Probably a function:
function RegexBuilder(kwd){
// I know I can use brutal force to search one by one,
// but I just need to know how to generate that regex?
return regex_expression;
}