Home All Groups Group Topic Archive Search About

how to: remove unequal white spaces with trim method

Author
31 Jan 2006 9:58 PM
Jan
Hi,

Is there a way to remove the white spaces between text?

For example:

"Section 1     is   oke      fine"

I want it to be,

"Section 1 is oke fine"

I know the method trim, but only for equal spaces. Can I use it for
unequal white spaces?

Thanx

--
Sent via .NET Newsgroups
http://www.dotnetnewsgroups.com

Author
31 Jan 2006 10:39 PM
CMM
I think you're going to have to write your own algorithm to do it... it's
not hard.
I love problems like this.... they're always good excercises.

You can probably use regular expressions to do it too.. I dunno... I prefer
hardcore algorithms to do stuff like this.

Show quoteHide quote
"Jan" <baggerd***@hotmail.com> wrote in message
news:eA093FrJGHA.1088@tk2msftngp13.phx.gbl...
> Hi,
>
> Is there a way to remove the white spaces between text?
>
> For example:
>
> "Section 1     is   oke      fine"
>
> I want it to be,
>
> "Section 1 is oke fine"
>
> I know the method trim, but only for equal spaces. Can I use it for
> unequal white spaces?
>
> Thanx
>
> --
> Sent via .NET Newsgroups
> http://www.dotnetnewsgroups.com
Author
31 Jan 2006 10:39 PM
Herfried K. Wagner [MVP]
"Jan" <baggerd***@hotmail.com> schrieb:
> Is there a way to remove the white spaces between text?
>
> For example:
>
> "Section 1     is   oke      fine"
>
> I want it to be,
>
> "Section 1 is oke fine"

\\\
MsgBox(System.Text.RegularExpressions.Regex.Replace("Foo   bar  Goo", "
( )*", " "))
///

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://classicvb.org/petition/>