lParameters tcStr, tcFind, tcRep Local lnPos, lcResult, lcRemainder, lnLenFind lcRemainder = tcStr lnPos = ATC(tcFind, lcRemainder) lnLenFind = LEN(tcFind) lcResult = '' Do While lnPos > 0 lcResult = lcResult + LEFT(lcRemainder, lnPos - 1) + tcRep lcRemainder = SUBST(lcRemainder,lnPos + lnLenFind) lnPos = ATC(tcFind, lcRemainder) EndDo RETURN lcResult + lcRemainderbut VBScript.RegExp is far more powerful, and does the same thing by:
oRegExp = CREATEOBJ)'VBScript.RegExp') oRegExp.Global = .t. oRegExp.IgnoreCase = .t. oRegExp.Pattern = tcFind && This configures the COM object - the next line does the translation && and may be called repeatedly without reinitializing the object. lcResult = oRegExp.Replace(tcStr,tcRep)and the regular expression parser supports a wide range of wildcarding, explicit positional scoping and control of string context. You can find details about it at the WSH sites from my sig block.