It's not clear at all to me what your reason for using
eval( ) is.
Is it simply so you can do it all in one line?
Not a good reason.
What's the difference between:
Code:
replace(eval("/"+var1+"/gi"), anything)
and
Code:
replace( (new RegExp( var1, "gi" ) ), anything )
???
Surely the second version is much more efficient, by avoiding the
eval( ).
Even if eval( ) isn't evil, it's certainly less efficient than most anything else. (Especially in MSIE, unsurprisingly.)