Sponsored Ad

Thursday, March 24, 2011

how to Remove Multiple Blank Spaces from a String using C# | Regular Expression

how to Remove Multiple Blank Spaces from a String using C# | Regular Expression

The below code will help developers to reduce the multiple (white)blank spaces in a string and convert into single space. This program is using regular expression to remove multiple spaces. while there is other ways are available to achieve the same.

using System;

namespace BlankSpaces_MyApp
{
    class _class
    {
        public static void Main(string[] args)
        {
            string str = " Software  Development            Using C# - C#         Tutorials ";
            string NewString = System.Text.RegularExpressions.Regex.Replace(str, @"\s+", " ");
            Console.WriteLine(NewString);

            Console.Read();
        }
    }
}

2 comments:

  1. Well, Great! Good thought-out info. Turning attention on cheapest solutions in house insurance, it is the best way to receive cheap house insurance.

    ReplyDelete
  2. Thank you so much. It was very helpful for me..

    Br.
    Rony

    ReplyDelete

Sponsored Ad

Development Updates