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?
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
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!
@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.
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
… 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:
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”