Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Public Sub splitUpRegexPattern()
- Dim regEx As New RegExp
- Dim strPattern As String
- Dim strInput As String
- Dim strReplace As String
- Dim Myrange As Range
- Set Myrange = ActiveSheet.Range("B2:B4279")
- For Each c In Myrange
- strPattern = "([A-Z]{2}/[A-Z]{2}/[A-Z][0-9]{2}/[a-z]{3}[0-9]{9}/)([0-9]{4})"
- If strPattern <> "" Then
- strInput = c.Value
- strReplace = "$1"
- With regEx
- .Global = True
- .MultiLine = True
- .IgnoreCase = False
- .Pattern = strPattern
- End With
- If regEx.test(strInput) Then
- c.Offset(0, 1) = regEx.Replace(strInput, "$2")
- Else
- c.Offset(0, 1) = ""
- End If
- End If
- Next
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement