passing variable to a regexp in javascript [duplicate]

Your regexp is /{0}/gi since you create it from a string. And it is not a valid expression.
You need to escape { in the regexp because it has a special meaning in the regexp syntax, so it should be:

new RegExp('\\{'+i+'\\}', 'gi');

which is /\\{0\\}/gi. You need to escape the escaping \\ in the string.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)