I have a row of cells in Excel that follow the following syntax:
randomtext VALUES (randomnumber, randomtext,
I have a VB script to split the text using regular expressions:
Public Function SplitRe(text As String, pattern As String, Optional ignorecase As Boolean) As String()
Static re As Object
If re Is Nothing Then
Set re = CreateObject("VBScript.RegExp")
re.Global = True
re.MultiLine = True
End If
re.ignorecase = ignorecase
re.pattern = pattern
SplitRe = Strings.Split(re.Replace(text, vbNullChar), vbNullChar)
End Function
The delimiter I'm using: (VALUES)+(\s+)+(.)+\d+(,)
This results in the text being split as:
randomtext
What I'm trying to achieve is to split the text after the script finds the delimiter, creating this:
randomtext VALUES (randomnumber,
But I can not find a way to properly augment my script to do so. Anyone see a solution?
VBScript.RegExpas a Static object. Can you add sample data together with expected results?