Quote:

Richard, can you post some example code?




It's really as simple as Jooel states. You would use it to remove redundant characters from strings such as spaces or blank lines in file text.

It's so useful that I have it as a UDF.
Code:
; udfTRIM()
;
; Remove repeated characters from string, also removes leading and trailing
; characters.
;
Function udfTrim($s,$c)
While InStr($s,$c+$c) $s=Join(Split($s,$c+$c),$c) Loop
If Left($s,1)=$c $s=SubStr($s,2) EndIf
If Right($s,1)=$c $s=Left($s,-1) EndIf
$udfTrim=$s
EndFunction



A couple of examples
  1. $s=udfTrim($s," ") ; remove redundant spaces from string
  2. $sFileData=udfTrim($sFileData,@CRLF) ; remove blank lines from data


[edit]Oops - removed the leading/trailing stuff as it didn't work for all cases.[/edit]

[edit]Updated leading/trailing stuff - not as pretty as original but it works.[/edit]


Edited by Richard H. (2005-06-27 03:58 PM)