WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Functions

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

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:   W14597
Filename:   StrClean Function.txt
File Created: 2000:10:16:11:17:40
Last Updated: 2000:10:16:11:17:40