[Gambas-user] trimming extra spaces from within a string.
Fabien Bodard
gambas.fr at gmail.com
Tue Nov 10 21:06:10 CET 2020
This is mine but I'm not able to test it in Fast mode ... But even in
'normal' it is more faster than rolf one :-)
If someone can find why I'm not able to get it running on fast mode...
Public Function FabienTrim(sRaw As String) As String
Dim s As String
Dim hStream As File
Dim bFirst As Boolean = True
hStream = Open String For Write
For i As Integer = 0 To Len(sRaw) - 1
s = sRaw[i]
If s = " " Then
If Not bFirst Then
Write #hStream, s
bFirst = True
Endif
Else
bFirst = False
Write #hStream, s
Endif
Next
s = Close #hStream
If bFirst Then s = Left(s, -1)
Return s
End
More information about the User
mailing list