fix to replaceFirst() on js