• Post Reply Bookmark Topic Watch Topic
  • New Topic

String Pattern Match  RSS feed

 
Michael Piaser
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can anyone see why the following string fails the test below: michelle.zischer@wagezorks.com



 
Michael Piaser
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Found it - there was a space at the end of the string
 
Paul Clapham
Sheriff
Posts: 22843
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It would help to have more than one data point -- in other words, it would help to be shown a list of strings which were allegedly well-formed e-mail addresses and another list which weren't.

I'd also point out that validating e-mail addresses just by looking at them is a risky thing. One false negative and you've annoyed a customer who can't get into your system with their perfectly reasonable e-mail address. Your regex, for example, accepts any two letters as a country code but then turns around and allows only a subset of the valid TLDs.
 
Tim Cooke
Marshal
Posts: 4051
239
Clojure IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're darned right about that Paul. I was infuriated by my email provider's webmail client because it considered apostrophe's as invalid characters for an email address. Made it very difficult to email my old colleague who's last name is O'Kelly.
 
Mike. J. Thompson
Bartender
Posts: 689
17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Plus one to that. The most common problem I find is not accepting the '+' character in emails which is pretty infuriating. The worst example I've seen though is a system that did let me use a '+' when registering, but then had not sanitised any of their HTML after that point. The end result was it used my email address as an HTTP post parameter unsanitised, and when it URL encoded the string my '+' character got turned into a space! The system was just broken.
 
Paul Clapham
Sheriff
Posts: 22843
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Correct me if I'm wrong -- my regex skills are pretty poor -- but I don't believe the OP's regex allows apostrophes in an e-mail address.
 
Mike. J. Thompson
Bartender
Posts: 689
17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It doesn't as far as I can see. An RFC compliant regular expression for emails is not a simple thing though. It goes on for several hundred lines. I was surprised to find that emails can contain comments too!

http://www.ex-parrot.com/~pdw/Mail-RFC822-Address.html
 
Paweł Baczyński
Bartender
Posts: 2087
44
Firefox Browser IntelliJ IDE Java Linux Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This article is also worth reading (link).
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!