troubleshooting Question

Modify vba function

Avatar of SAbboushi
SAbboushiFlag for United States of America asked on
Visual Basic ClassicOutlookVB Script
4 Comments1 Solution801 ViewsLast Modified:
Would like the attached code to also handle the following 3 scenarios:


Desired Result:
Name= ""
Address = ""

Desired Result:
Name= ""
Address = ""

3) Sam Abboushi <>
Sam Abboushi []
Sam Abboushi (
Desired Result:
Name= "Sam Abboushi"
Address = ""

Function splitAddy(str As String) As Variant
Dim regEx As Object
Dim matchCollection As Object

Debug.Print splitAddy("fred smith <>")(1)
Debug.Print splitAddy("fred smith <>")(0)
fred smith

    Set regEx = CreateObject("vbscript.regexp")
    With regEx
        .Pattern = "([\w|-]*)[,; ] *([\w|-]*) *(?:[\[|{|(|<])([\w|-]*@[\w|-]*.[\w|-]*)(?:[\]|}|)|>])"
        .Global = True
        .IgnoreCase = True
    End With
    Set matchCollection = regEx.Execute(str)
    If matchCollection.Count = 0 Then
        splitAddy = ""
        splitAddy = Array(matchCollection(0).submatches(0) & " " & matchCollection(0).submatches(1), matchCollection(0).submatches(2))
    End If

End Function
Join our community to see this answer!
Unlock 1 Answer and 4 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros