change RegExp['$n']  to RegExp.$n