cancel
Showing results for 
Search instead for 
Did you mean: 

Validating Input Email Address via regex

ganesh_s7
Participant
0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

lambert-giese
Active Participant
0 Kudos

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

ganesh_s7
Participant
0 Kudos

Thanks Lambert.  I will check the expression and get back.

lambert-giese
Active Participant
0 Kudos

For those who need such kind of validation for optional attributes, the regex will need to allow empty value as well. The following modification does exactly that:

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

Answers (1)

Answers (1)

normann
Advisor
Advisor
0 Kudos

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

ganesh_s7
Participant
0 Kudos

Hi Norman,

It will be great to know the alternative.

Pardon me, i am not sure what is meant by 'PM'.

With Regards,

Ganesh.S

former_member2987
Active Contributor
0 Kudos

Hi Ganesh,

Normal is referring to Private Message (referred to as a Direct Message here on SCN) In order do to this, I believe you must be following each other first.

Regards,

Matt

ganesh_s7
Participant
0 Kudos

Hi Matt,

Thanks for the info.

Regards,

Ganesh