Created
May 29, 2014 13:45
-
-
Save weeksdev/3f7b5bc08943a9a4c01a to your computer and use it in GitHub Desktop.
RegEx Parse
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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