regex - Validation issue in email for minimum length in javascript -


i using below regex validate email , working fine in of scenarios. though specified minimum length of email 5 accepting 2 minimum length.so change in order accept minimum length 5 chars

(?=^.{5,254}$)(^(?!.*__.*)[a-z0-9]+(_?)*[a-z0-9]+(?:\\.[a-z0-9!#$%&*+/=?^`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9]*[a-z0-9])?$) 

i specified minimum , max length @ beginning of regex

seems there problem in way have positioned min max limit:

(^(?!.*__.*)[a-z0-9]{4,253}(_?)[a-z0-9]+(?:\.[a-z0-9!#$%&*+\/=?^`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9]*[a-z0-9])?$) 

demo here: https://regex101.com/r/dg7vz8/1

the min length allowed here 5 chars

you can see {4,253} written latter part of regex matches 1 character before @ symbol


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -