Revision cbaa9e32-71f9-4fd2-80a9-bc1135e6be93 - Stack Overflow
> **Possible Duplicate:**
> [Escape string for use in Javascript regex](https://stackoverflow.com/questions/3446170/escape-string-for-use-in-javascript-regex)
<!-- End of automatically inserted text -->
I have a msg like this:
> **Max {0} chars allowed in {1}**
And I have a function to create a message using the arguments passed as
for(var i = 0; i < agrs.length; i++){
reg = new RegExp('\{'+i+'\}', 'gi');
key = key.replace(reg,agrs[i])
}
The problem is that it's not able to take the param `i` to create the reg exp.
What's the way to achieve this?