Tokenizing strings

I have about 100 lines of text that I want tokenize, which are similar to the following:

<word> <unknown number of spaces and tabs> <number>

I am having trouble finding tokenize functions with VBA. What would be the easiest way to tokenize such strings in VBA?

+3
source share
3 answers

You can read line by line and use the split function to split words and numbers into spaces. I vaguely remember that VBA has a split function.

I got the following link by doing a google search. Not sure which version of the office you are using.

http://msdn.microsoft.com/en-us/library/aa155763(office.10).aspx

This link has a split function.

+3
source

Split() , "vbscript.regexp":

Sub NewRegex()
    Dim reg
    Dim matches, match, tmpStr As String

    Set reg = CreateObject("vbscript.regexp")
    tmpStr = "blah bla ...."

    With reg
        .IgnoreCase = True
        .MultiLine = False
        .Pattern = "your regex pattern goes here"
        .Global = True
    End With

    Set matches = reg.Execute(tmpStr)

    For Each match In matches
        MsgBox match
    Next mt

End Sub

regex VBA: (RegExp) Excel

+2
0
source

Source: https://habr.com/ru/post/1712356/


All Articles