Android Question How get domain name between @ and . of the e-mail

Alisson

Active Member
Licensed User
Hello

I need get the name domain name between '@' and '.' of the e-mail. Example:

store@domainname.com

Result: domainname

I try one regx, but not have successful.
I don't Known use the regex:

Regex.Matcher("^(?i)[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])$", "store@domainname.com")

Someone can help me, please?

Thanks very much!
 

DonManfred

Expert
Licensed User
Longtime User
A simple split should do the trick.
Split at @
Split result again at the dot.
 
Upvote 0

Alisson

Active Member
Licensed User
Erel and DonManfred.

I found it:

B4X:
Dim data As String
data = "john@gmail.com"
Dim matcher1 As Matcher
matcher1 = Regex.Matcher("@\w+\.", data)
Do While matcher1.Find = True
    Log(matcher1.Match)
Loop

Thanks very much guys! :)
 
Upvote 0
Top