Trim leading spaces including tabs

后端 未结 4 1000
醉酒成梦
醉酒成梦 2020-12-19 13:20

I need to read files using vbscript and remove all leading spaces including any tabs. I now LTRIM will remove the leading spaces but how do I remove tabs also.

Thank

4条回答
  •  清歌不尽
    2020-12-19 13:53

    For a both left and right trim (including tabs, carriage return, line feeds, spaces) in a multiline string this will work.

    Function MultilineTrim (Byval TextData)
        Dim textRegExp
        Set textRegExp = new regexp
        textRegExp.Pattern = "\s{0,}(\S{1}[\s,\S]*\S{1})\s{0,}"
        textRegExp.Global = False
        textRegExp.IgnoreCase = True
        textRegExp.Multiline = True
    
        If textRegExp.Test (TextData) Then
            MultilineTrim = textRegExp.Replace (TextData, "$1")
        Else
            MultilineTrim = ""
        End If
    End Function
    

提交回复
热议问题