Reputation:
For example, I've got var for RegEx DSX-?2
I need add this var to RegEx and get this .match(/DSX-?2/gi)
Upvotes: 2
Views: 581
Reputation: 13327
You can create a RegExp
object by using the new RegExp()
constructor or by assigning a RegExp literal to a variable:
var pattern1:RegExp = /DSX-?2/gi;
// or
var pattern2:RegExp = new RegExp("DSX-?2", "gi");
Upvotes: 3