user2090666
user2090666

Reputation: 1

Extract email address from string with variable length

How do I extract an email address from a string?

xxx [email protected] yyy

xxx and yyy can be any length, any character. The email address is delimited by spaces.

Upvotes: 0

Views: 412

Answers (1)

Fionnuala
Fionnuala

Reputation: 91366

One possibility:

sString = "[email protected] xxx [email protected] yyy [email protected]"
asString = Split(sString, " ")
For i = 0 To UBound(asString)
    If asString(i) Like "*@*.*" Then
        sEmail = sEmail & "," & asString(i)
    End If
Next

MsgBox Mid(sEmail, 2)

Upvotes: 2

Related Questions