Ok, so I have a fabulous little function which uses a regular expression to check if a string is a valid email address or not:
it works great and returns the boolean "True" if the string is a valid email address and "False" if it is not.
However...
My users are starting to be a little clever, and want to include MULTIPLE email addresses in their input fields separated by semi-colons...
So for example: Joe.Bloggs@somemail.com; Dave.Bloggs@somemail.com; Steve.Bloggs@somemail.com
This doesn't break anything EXCEPT for my validity checker, which sees them as one long, invalid string.
I'm not very good with regular expressions, I got the expression in my function from this forum. Is there a way that my expression could be modified to allow this type of list to be checked? It would need to be able to check any number of email addresses.
If that can't be done with a regular expression, how could I modify my function so it sees this type of list as valid?
Code:
Function isemail(inputtext As String) As Boolean
'Detects if a text string is a valid email address
isemail = False
With CreateObject("VBScript.RegExp")
.Pattern = "^[\w-\.]+@([\w-]+\.)+[A-Za-z]{2,3}$"
If .test(inputtext) Then
isemail = True
End If
End With
End Function
it works great and returns the boolean "True" if the string is a valid email address and "False" if it is not.
However...
My users are starting to be a little clever, and want to include MULTIPLE email addresses in their input fields separated by semi-colons...
So for example: Joe.Bloggs@somemail.com; Dave.Bloggs@somemail.com; Steve.Bloggs@somemail.com
This doesn't break anything EXCEPT for my validity checker, which sees them as one long, invalid string.
I'm not very good with regular expressions, I got the expression in my function from this forum. Is there a way that my expression could be modified to allow this type of list to be checked? It would need to be able to check any number of email addresses.
If that can't be done with a regular expression, how could I modify my function so it sees this type of list as valid?