Reputation: 304
I have a textbox in which a user can type comma separated email addresses. User can only email within a specific domain defined in the regular expression. Currently, I am validating the input by using
If Regex.IsMatch(txtEmailto.Text.Trim, "\b\w+(@abc.com)\b") = False Then
MsgBox("Please enter a valid Send Email to")
Exit Sub
My regular expression is working for the first email address in the textbox but nothing after the comma. I would like to get the regular expression so that it would go through all the text and return false if any of the email address are outside of abc.com domain.
Upvotes: 0
Views: 701
Reputation: 1943
Dim emails As String() = txtEmailto.Text.Split(",")
For Each email As String In emails
If Regex.IsMatch(email.Trim, "\b\w+(@abc.com)\b") = False Then
MsgBox("Please enter a valid Send Email to")
Exit Sub
End If
Next
Upvotes: 1