Skip to Content

Validating Input Email Address via regex

Hi Experts,

We have a requirement to validate Input email address for External Partners to be an email address from non-client domain.

Planning to validate the same using regex in 'Validation' tab of custom attribute 'Z_TEMP_EMAIL_EXT', mapped to the UI task used for External User ID creation.

Client has two email domains, namely 'FN.LN@clientabc.com' and 'FN.LN@xyzclient.com'

I have arrived at below regex for validating the client domain; and attempts to ensure these are NOT input (negative condition) are not working.


Please suggest how to validate regex for NOT including these domains. 

(1) "^(.*)[\@](clientabc|xyzclient)[\.](com)"

(2) "^(.*)[\@](clientabc|xyzclient)[\.](.*)"

(3) "(\Qclientabc\E)|(\Qxyzclient\E)"

With Regards,

Ganesh.S

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    Feb 02, 2015 at 11:06 AM

    Hello Ganesh,

    you want negative lookahead with alternation, like this:

    .+@(?!clientabc\.com$|xyzclient\.com$).+

    Please note, though, that the above regex does not provide any POSITIVE guarantee that the input is a valid SMTP address as specified by RFC2821.

    It just provides a negative guarantee that the input is NOT an SMTP address from domains clientabc.com or xyzclient.com.

    Best regards,

    Lambert

    Add comment
    10|10000 characters needed characters exceeded

  • Feb 02, 2015 at 05:38 PM

    Hello Ganesh,

    another approach would be to use the UI extension classes if your requirements are too complex for Java regex.

    I can give you some more useful information in PM if necessary.

    Regards

    Norman

    Add comment
    10|10000 characters needed characters exceeded