Android Code Snippet [B4X] Check Valid E-Mail Format

Alexander Stolte

Expert
Licensed User
B4X:
Private Sub EmailAddressCheck(email As String) As Boolean   
    Return Regex.IsMatch("^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$",email)
End Sub
Example:
If EmailAddressCheck("test@b4x.de") = True Then
        Log("E-Mail is valid")
        Else
        Log("E-Mail is not valid")
    End If
 

toby

Active Member
Licensed User
B4X:
    If Regex.IsMatch(".+@.+\..+", req.GetParameter("email")) = False Then
        resp.SendError(500, "Invalid email address.")
    End If
I found this code inside FormExampleHelper class in ServerHelloWorld.zip.
It's for B4J only; correct me if I'm wrong.
 
Top