When you are dynamically generate RegEx strings, its always better to use RegExp constructor. / is actually to tell JavaScript that you are going to use a Regular Expression literal. But when you put that inside quotes, it becomes a part of the string.
The simplest way to do this is to put them in a list like this
var data = ["iphone", "ipod", "ipad"];
And join them with | like this
agent.match(new RegExp("(" + data.join("|") + ")"))
This works because,
data.join("|")
will produce
iphone|ipod|ipad
We can concatenate ( and ) with that string to dynamically generate the pattern you wanted.