How To Remove all spaces from inside a string value in VB.NET

Discussion in 'Programming' started by largn81, Jan 26, 2008.

  1. #1
    Code: :)
    Source

    Public Function NoWhiteSpace(ByVal strText As String) As String
    Return System.Text.RegularExpressions.Regex.Replace(strTe xt, " ", _
    String.Empty, System.Text.RegularExpressions.RegexOptions.Ignore Case)
    End Function

    Demo

    Dim Test As String = " This is a simple test for No white spaces function "
    Console.WriteLine("The original text is [{0}] and the replacement is [{1}]", _
    Test, RemoveWhiteSpace(Test))
     
    largn81, Jan 26, 2008 IP