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

Christof Thalhofer chrisml at deganius.de
Tue Nov 10 00:25:57 CET 2020


Am 09.11.20 um 23:52 schrieb Fabien Bodard:

> And .. sorry I'm on phone but
> 
> Just walk on the string if not space add to new string ...if first space
> too... jump to the next not space letter ...etc ?
> 
> Is this not more faster than using a recursive call to replace ?
> 
> The 3 ms gain from benoit can come from the fact he not use trim.

That (3 ms) was just a joke because from run to run it differs between
something about 2200 and 2400 ms.

So I can see no difference at all between Benoît's solution and the
while ... wend loop. Both are about three times faster than the Regexp
and a couple of hundred times faster than Brians solution.

If anyone wants to try it out here is the text I used to test it:

https://paste.c-net.org/HoustonRoxanne

It is some dadaistic poetry.

Alles Gute

Christof Thalhofer

-- 
Dies ist keine Signatur

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: OpenPGP digital signature
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20201110/fafbe86a/attachment.sig>


More information about the User mailing list