Docs: Email begins with # does not match

Created on 11 May 2018  Â·  6Comments  Â·  Source: dotnet/docs

[email protected] will not match from the regex above.


Document Details

⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

Area - .NET Guide P1 doc-enhancement external

Most helpful comment

And a thought on high traffic, low satisfaction: most probably that comes from those folks who type in Google something like .NET validate email address and land in on this page, see that long-long regex, fight through the table to understand it, and then—at the end of the day—they see the note... That, kind of, might make them angry of all the wasted time. Of course they would say that that page was not helpful.

So, stating at the beginning what is the target audience and redirecting those Google "victims" might fix low satisfaction score.

All 6 comments

apart from that, is email really a good example for RegEx usage?

IMHO, docs could (should?) point to System.Net.Mail.MailAddress for email addresses, even though there is no TryParse method (https://github.com/dotnet/corefx/issues/25295).

@terrajobst @weshaggard should we update that topic to use the API instead of regexes? That topic has a lot of page views but low CSAT, so it would be good to address this.

I agree that for email addresses MailAddress is likely better although currently it throws on invalid email addresses. However this doc was intended as a RegEx example not a email parsing example. So if we would need to come up with another example if we were to switch. For better or worse parsing email addresses is a common RegEx example so I think we should just fix the current article. It might be worth adding a note that this is just an regex example but validating email addresses in .NET might be easier done with MailAddress.

@dasMulli @weshaggard the article already contains the note about System.Net.Mail.MailAddress and MailAddress constructor as an alternative to regex (see the note just above the Compiling the code section). Maybe it should be rephrased in such a way that makes the MailAddress using more preferable to the suggested regex example and placed at the start of the topic.

That would tell from the beginning that that topic is about how to use regex, just an example, possibly flawed, but one is welcome to go through it and learn something about regex. If one is interested in parsing e-mail address, the note navigates her/him to the right direction from the start and one would not waste time on the regex example if it's not the point of interest.

And a thought on high traffic, low satisfaction: most probably that comes from those folks who type in Google something like .NET validate email address and land in on this page, see that long-long regex, fight through the table to understand it, and then—at the end of the day—they see the note... That, kind of, might make them angry of all the wasted time. Of course they would say that that page was not helpful.

So, stating at the beginning what is the target audience and redirecting those Google "victims" might fix low satisfaction score.

@Mehmet-Erkan Hi! After pondering this and #9438 and #7184 for a while, I've decided not to fix this. There are many discussions on the internet about using regex for email validation and how it seems almost impossible to get the "perfect" regex.

There are many other valid things you can put in that email validation test that actually fail. This sample isn't meant to be the best email validation test, it's simply meant to be there as an example.

You'll need to customize the regex to fit your needs, or find another validation regex to use in its place.

As stated in some of the comments, it may be more appropriate for this article to just disappear.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tswett picture tswett  Â·  3Comments

skylerberg picture skylerberg  Â·  3Comments

garfbradaz picture garfbradaz  Â·  3Comments

mekomlusa picture mekomlusa  Â·  3Comments

stanuku picture stanuku  Â·  3Comments