Jump to content

Removing white space for email adress


Nic727

Recommended Posts

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 by Nic727
Link to comment
Share on other sites

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...