add @pameptos fix, very important g param on regexp replace implementation