Regular Trim function only removes preceding and trailing space but it does not remove all other white space characters e.g. New Line(\n), Carraige return(\r), Form Feed(\f), Tab(\t). To remove these characters you can easily implement function using Regular expression. |
Click here to copy the following block | Function TrimEx(ByVal inString As String) As String Dim reg1 As String = "^(\s*)([\W\w]*)(\b\s*$)" Dim re As New System.Text.RegularExpressions.Regex(reg1)
TrimEx = re.Replace(inString, "$2") End Function |
|