Changed both replacetext and replaceglobal to use regex instead of the native string replace.