Nic727 Posted September 14, 2016 Share Posted September 14, 2016 (edited) Hi, I'm currently building my regex to validate email and it's a bit complicated since a lot of things can work. Currently I have something like that : ^[a-z\d!#$%&'"*+-/=?^_`{|}~.,]+@[a-z\d-]+\.([a-z]{2,5})$/i I allowed 2 to 5 character after the final dot. But in Canada we have things like .gc.ca for the government. Also, ' and ` is the same thing right or not? One other thing I saw on Outlook login is that they are removing white space and I would like to know how. For example, " email@hotmail.com " will be the same as "email@hotmail.com" and will be valid (I'm able to login with it). White space will not work if it's in the email itself. Thank you PS: I would also like to know how to make character with accents working like é, à, ë, etc. Edited September 14, 2016 by Nic727 Link to comment Share on other sites More sharing options...
Ingolme Posted September 14, 2016 Share Posted September 14, 2016 Whitespace is usually removed on the server side. In PHP you can use the trim() function. In Javascript you can just add whitespace to your regular expression: /^\s* ... \s*$/i Link to comment Share on other sites More sharing options...
justsomeguy Posted September 14, 2016 Share Posted September 14, 2016 The pattern for after the at sign should be 0 or more groups of a letter followed by 1 or more letters or numbers, followed by a dot, then after 0 or more of those groups you have the final top level domain. It would be valid to have email@sub1.sub2.sub3.sub4.com, for example. It would also be valid to have an email address like user@local. There is no limit to the number of subdomains, you can have 0 or more. That's what your pattern needs to show. Also, ' and ` is the same thing right or not?Those are 2 different characters. PS: I would also like to know how to make character with accents working like é, à, ë, etc.Your pattern needs to allow Unicode characters in a certain range. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now