Imports System
Imports System.Text.RegularExpressions
Public Class Program
Public Shared Sub Main()
Dim s As String = "vb.net " & Environment.NewLine &
" c c++ " & Environment.NewLine &
" java python" & Environment.NewLine
s = RemoveNewLines(s) ' result without extra spaces
Console.Write(s)
End Sub
Private Shared Function RemoveNewLines(input As String) As String
If input Is Nothing Then
Return String.Empty
End If
' Replace any run of whitespace (spaces, tabs, newlines, etc.) with a single space
input = Regex.Replace(input, "\s+", " ")
Return input.Trim()
End Function
End Class
' run:
'
' vb.net c c++ java python
'