/ Published in: JavaScript
Use the RegExp constructor to create the regular expression. You can pass RegExp any string as an argument and it will be converted to a regex.
Expand |
Embed | Plain Text
var baz = "foo"; var filter = new RegExp(baz + "d") "food fight".match(filter); // returns ["food"]
You need to login to post a comment.
