Skip to content

Instantly share code, notes, and snippets.

@weeksdev
Created May 29, 2014 13:45
Show Gist options
  • Select an option

  • Save weeksdev/3f7b5bc08943a9a4c01a to your computer and use it in GitHub Desktop.

Select an option

Save weeksdev/3f7b5bc08943a9a4c01a to your computer and use it in GitHub Desktop.
RegEx Parse
Sub RegExParse()
Dim RE As Object, REMatches As Object
Dim pattern As String
Set RE = CreateObject("vbscript.regexp")
pattern = "\[(.*?)\] \["
With RE
.MultiLine = False
.Global = False
.IgnoreCase = True
.pattern = pattern
End With
Dim x As Integer
x = 1
Do While Range("A" & x).Value <> ""
Set REMatches = RE.Execute(Range("A" & x).Value)
Range("B" & x).Value = REMatches(0).SubMatches(0)
x = x + 1
Loop
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment