Option
Explicit
Public
Function
tokenize()
As
Boolean
Dim
objRegEx
As
Object
Dim
objMatches
As
Object
Dim
strExpr
As
String
Dim
rngRow
As
Excel.Range
Dim
rngCell
As
Excel.Range
With
Worksheets(
"Tabelle1"
).Range(
"A1"
).CurrentRegion
For
Each
rngRow
In
.Rows
If
strExpr <>
""
Then
strExpr = strExpr & vbNewLine
For
Each
rngCell
In
rngRow.Cells
strExpr = strExpr &
" "
& rngCell.Value
Next
Next
End
With
With
CreateObject(
"VBScript.RegExp"
)
.Pattern =
"([a-z][\w\d]+) +(FROM|(?:(?:(?:LEFT|INNER|RIGHT) *)?JOIN)) +((?:(?:[a-z][\w\d]+))(?: +(?:[a-z][\w\d]+))?)"
.IgnoreCase =
True
.MultiLine =
True
.Global =
True
Set
objMatches = .Execute(strExpr)
End
With
Dim
o
As
Variant
Dim
i
As
Long
Dim
j
As
Long
Application.ScreenUpdating =
False
With
Worksheets(
"Tabelle3"
)
For
i = 0
To
objMatches.Count - 1
.Cells(1 + i, 1).Value = objMatches(i).SubMatches(0)
.Cells(1 + i, 2).Value = objMatches(i).SubMatches(2)
.Cells(1 + i, 3).Value = objMatches(i).SubMatches(1)
Next
End
With
Application.ScreenUpdating =
True
End
Function