Request for edit to support article: Regex

Hi, a colleague used the regex given in this support article to validate email addresses:

HOWEVER this regex only allows email addresses with a single . after the @ - thus ruling out any domains with a third level (i.e. most countries outside the US) - i.e. rules out
@example.co.uk @example.org.nz @example.gov.hu

Can you please fix your support article so that it’s something that works for all worldwide email addresses?

Thanks a lot!

1 Like

Hi @nat,

Best,

1 Like

Sure, thanks @hakan_cetinkaya for the updated regex! I think the support article still needs to be corrected though, as people copying and pasting from the examples in the article rightfully assume that the examples will work!
Maybe @Kal_Lam and team can update the article with your sample instead? Thanks again

3 Likes

Thank you, @hakan_cetinkaya, for sharing this workaround with @nat and @esario! We will update the article soon and let you know.

1 Like

Hi @Kal_Lam may you please update the article asap? People are still referring to it and putting the wrong regex in their forms for email validation. I’ve just seen the same gremlin in another new one created since this post. Should be a quick change - thanks a lot!

2 Likes

Thank you, @nat, for the follow-up. We will update it soon!

@nat, the article has finally been updated. You should be able to go through it here. Thank you for bringing this to our attention. Apologies for the delayed action.

1 Like

Hi @Kal_Lam thanks but the article still has the incorrect regex ;(
Thanks for adding the second row - but the first row is still showing and it’s the one that doesn’t work for a huge number of email addresses in a number of countries around the world. Can you please remove the first example (I’ve put a red line through it here)?


Maybe change the example given as well, so that it’s showing something that correctly meets the regex - i.e. example@domain.com or example@domain.co.uk

Thanks a lot, greetings to you.

2 Likes

@nat, thank you for flagging this. The main motive for keeping the top regex code:

regex(., '^[A-Za-z0-9._%+-]+@[A-Za-z0-9-]+[.][A-Za-z]{2,}$')

… is to control the email to only this format: example@domin.com (and nothing more than this, as most of the common email ids, are example@gmail.com or example@yahoo.com.com. It could also have example.example@gmail.com or example_example@yahoo.com.com. So that is why we kept the regex code as one example.

The second regex code is a bit flexible:

regex(., '^([\W\d\D]+[@][\D]+[.][\D]{2,})+$')

… this is because it can capture both example@domin.com and example@domin.com.np. If we keep only this regex code and assume the code to capture only example@domin.com and not example@domin.com.np, then the code fails as the code also allows users to input and email id with this format example@domin.com.np.

So this was the reason for having both regex codes separately.

Yes, for one thing, you got the typo error correct.

example.domin.com should be example@domin.com

and …

example.domin.com.np should be example@domin.com.np.

So would it be OK, if I propose the change to be as follows:

Let me know your thoughts! Thank you once again for all the support on flagging this issue.

Hi @Kal_Lam,

Speaking of typos, I think domin should also be domain

1 Like

Thank you, @hakan_cetinkaya! Will make changes accordingly! Much appreciated!

1 Like

I think if people explicitly want to limit to @yahoo.com or @gmail.com then they should specify that in the regex. It is misleading to say that the first example is restricting to “a valid email address” as there are huge numbers of valid email addresses in the world that don’t fit the @domain.com model. If you really want to keep the first example in then you would need to change the description to, for example, “Restrict an input to only a certain subset of valid email addresses”. I still think the first example should be removed though, as it is going much more restrictive than “valid email address”

1 Like

Hello.@Kal_Lam,
maybe the following can help.

There is an international official standard
RF 5322 (and 6854).

Of course, depending on the survey’s environment/location further restrictions often make sense.

2 Likes