[Gambas-user] trimming extra spaces from within a string.

Bruce Steers bsteers4 at gmail.com
Mon Nov 9 15:11:27 CET 2020


Is there a function like this for cleaning up a string of erroneous spaces
..













*Public Sub InTrim(sVar As String) As StringDim sOld, sNew, sChar, sLast As
String, iPos As IntegersOld = Trim(sVar)sNew = ""For iPos = 0 To sVar.Len -
1 sChar = sVar[iPos, 1] If IsSpace(sChar) And IsSpace(sLast) Then
Continue sNew &= sChar sLast = sCharNextReturn Trim(sNew)End*

That will turn " This    has    many        spaces  "
into "This has many spaces"

cheers
BruceS
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20201109/a8dc3179/attachment.htm>


More information about the User mailing list