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

Bruce Steers bsteers4 at gmail.com
Mon Nov 9 19:35:52 CET 2020


No my friend that will not work..
This does...
*While InStr(strinput,"  ")*

*strinput = Replace(strinput, "  ", " ")*

*Next*
*strinput = Trim(strinput)*

I already tried that :) it worked okay.
I found various ways, the initial function i posted seemed to me to be the
"gambas" way of doing it.
Although if it was Benoíts code he'd probably use String.Mid$() and not a
boxed string like i did :)

I was just curious to know if i wasn't missing a function in gambas that
already existed to do it :)

Cheers :)

On Mon, 9 Nov 2020 at 16:47, KKing <kicking177 at gmail.com> wrote:

> how about
> strInput = " This    has    many        spaces  "
> strResult = Trim(Replace(strInput,"  "," "))
>
> > That will turn " This    has    many        spaces  "
> > into "This has many spaces"
>
>
> ----[ http://gambaswiki.org/wiki/doc/netiquette ]----
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20201109/9cade402/attachment.htm>


More information about the User mailing list