Cecil
19+ years progress programming and still learning.
HI Guys,
I want to share a quick and simple email validation checker function.
Using .NET regex methods, I've created a simple email validation checker which returns a logical value.
It does not verify the email address as being valid.
I've had to base64 encode the regex expression because it was too hard to contain in the source code.
I want to share a quick and simple email validation checker function.
Using .NET regex methods, I've created a simple email validation checker which returns a logical value.
It does not verify the email address as being valid.
I've had to base64 encode the regex expression because it was too hard to contain in the source code.
Code:
using System.*.
using System.Text.RegularExpressions.*.
FUNCTION validateEmailAddress RETURN LOGICAL
(INPUT pcEmailAddress AS CHARACTER):
DEFINE VARIABLE cEncRegEx AS CHARACTER NO-UNDO.
DEFINE VARIABLE cRegEx AS CHARACTER NO-UNDO.
DEFINE VARIABLE mpRegEx AS MEMPTR NO-UNDO.
cEncRegEx = "Xig/KCIiKSgiIi4rPyg/PCFcXCkiIkApfCgoWzAtOWEtel0oKFwuKD8hXC4pKXxbLSEjXCQlJidc" +
"KlwrLz1cP1xeYFx7XH1cfH5cd10pKikoPzw9WzAtOWEtel0pQCkpKD8oXFspKFxbKFxkezEsM31c" +
"Lil7M31cZHsxLDN9XF0pfCgoWzAtOWEtel1bLTAtOWEtel0qWzAtOWEtel0qXC4pK1thLXowLTld" +
"W1wtYS16MC05XXswLDIyfVthLXowLTldKSkk".
mpRegEx = BASE64-DECODE(cEncRegEx).
cRegEx = GET-STRING(mpRegEx, 1).
RETURN Regex:IsMatch(pcEmailAddress, cRegEx, RegexOptions:IgnoreCase).
FINALLY:
SET-SIZE(mpRegEx) = 0.
END.
END FUNCTION.
MESSAGE
validateEmailAddress ("somebody@domainthingy.com") SKIP
validateEmailAddress ("somebody@domainthingy") .