300x250 AD TOP

Wednesday, June 29, 2011

Tagged under: ,

How to remove extra whitespace using regex, remove additional whitespace using regex

How to remove extra white space using regex, remove additional white space using regex


I was wondering if  there is an easy way to remove additional white spaces.I don't want to reamove all the white spaces but i just want to remove extra spaces keeping one space.

  Input:How         to    remove    additional White      space ?
Output:How to remove additional White space ?

There are few fuctions  such as Trim()  or Replace() but Regex really makes it very eash for us

Solution:
You can always use
System.Text.RegularExpressions.Regex.Replace(input, @”\s+, ” “);

Hope this helps.

Incoming Search items:
  • How to remove extra white space using regex
  • Regex to  remove extra white space
  • C# sharp  remove extra white space
  • remove additional white space from string
  • white space from string using regex

0 comments:

Post a Comment