Return to Snippet

Revision: 29232
at July 24, 2010 02:32 by krlogin11


Initial Code
''' <summary>
    ''' Removes extra leading whitespace, trailing whitespace and inside whitespace
    ''' </summary>
    ''' <param name="_string">String to remove extra whitespace</param>
    ''' <returns>Cleaned string.</returns>
    ''' <remarks></remarks>
    Public Shared Function RemoveExtraWhitespace(ByVal _string As String) As String
        If (_string = Nothing Or _string = " ") Then
            Return Nothing
        End If
        _string = _string.Trim()
        Dim stringArray() As String = _string.Split(" ")
        Dim tempString As String = Nothing
        For Each stringElement In stringArray
            If (stringElement <> "") Then
                tempString += " " + stringElement
            End If
        Next
        tempString = tempString.Trim
        Return tempString
    End Function

Initial URL

                                

Initial Description

                                

Initial Title
Remove Extra Whitespace In String

Initial Tags

                                

Initial Language
VB.NET