StrClean versus StrReplace
Keywords: StrClean versus StrReplace
Question:
The following code does not function as I think it should. I'm expecting the resulting msg to read, "Have a rotten night," but instead a get gibberish with the "rotten" string repeated multiple times. What do I need to change?a = "" a = StrClean("Have a nice day","nice","rotten",@TRUE,1) a = StrClean(a,"day","night",@TRUE,1) Message("", a) Drop(a)Answer:
StrClean is not designed to do what you want. StrClean is going to replace each 'character' with the corresponding replacement string..I think the function you want is StrReplace, which replaces all occurrences of a sub-string with another.
a = "Have a nice day" a = StrReplace(a ,"nice","rotten") a = StrReplace(a,"day","night") Message("", a) Drop(a)
Article ID: W14597Filename: StrClean Function.txt