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

String Manipulation

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

Replace Multiple Characters in a String

Keywords: 	 UDF replace multiple characters in a string

This can remove any specified consecutive multiple character, such as replacing multiple spaces with a null.
#DefineFunction CharTrim(ipstr,trimchar)
  i=0
  while @TRUE
    i=i+1
    if i>1000 then break                          ; check for infinite loop
    ipstr=StrReplace(ipstr,"%trimchar%%trimchar%","%trimchar%") 
    if StrIndex(ipstr,"%trimchar%%trimchar%",1,@FWDSCAN)==0 then break   ;no more multiple characters
  endwhile
  return ipstr
#EndFunction

Article ID:   W15012
File Created: 2001:11:08:12:41:20
Last Updated: 2001:11:08:12:41:20