There is such a regular expression for checking Email:

pattern="^[A-Za-z0-9][A-Za-z0-9\.-_]*[A-Za-z0-9]*@([A-Za-z0-9]+([A-Za-z0-9-]*[A-Za-z0-9]+)*\.)+[A-Za-z]*$" 

Tell me, please, why not skip:

my-email@ukr.net

In this case, my_email@ukr.net and my.email@ukr.net skips.

1 answer 1

Because the hyphen also needs to be escaped with a backslash:

 pattern="^[A-Za-z0-9][A-Za-z0-9\.\-_] 

Since in the current record \.-_ hyphen character is perceived as a range character, and not as one simple character.

  • Students shoals gone? :) ru.stackoverflow.com/questions/562760/… - vikttur
  • one
    @edem, you can not escape if it stands next to the bracket. - Visman September
  • @Visman, yes, you are right, it is possible and so. - edem