I know this is an old question, but I figured out to get the email regular expression. In current version (22.0.5) you can look at org.keycloak.utils.EmailValidationUtil on server-spi-private project in case you want more detail. Keycloak executes two regex validations, one for the local part and the second for the domain. This are the regex:
LOCAL_PART_PATTERN: (?:[a-z0-9!#$%&'*+/=?^_
{|}~\u0080-?\uFFFF-]+|"(?:[a-z0-9!#$%&'.(),<>[]:; @+/=?^_{|}~\u0080-?\uFFFF-]|\\\\|\\\")+")(?:\.(?:[a-z0-9!#$%&'*+/=?^_
{|}~\u0080-?\uFFFF-]+|"(?:[a-z0-9!#$%&'.(),<>:; @+/=?^_{|}~\u0080-?\uFFFF-]|\\\\|\\\")+"))*
DOMAIN_PART_PATTERN: (?:[a-z\u0080-?\uFFFF0-9!#$%&'*+/=?^
{|}~]-)[a-z\u0080-?\uFFFF0-9!#$%&'+/=?^{|}~]++(?:\.(?:[a-z\u0080-?\uFFFF0-9!#$%&'*+/=?^
{|}~]-)[a-z\u0080-?\uFFFF0-9!#$%&'+/=?^{|}~]++)*|\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\]|\[IPv6:(?:(?:[0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|(?:[0-9a-fA-F]{1,4}:){1,7}:|(?:[0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|(?:[0-9a-fA-F]{1,4}:){1,5}(?::[0-9a-fA-F]{1,4}){1,2}|(?:[0-9a-fA-F]{1,4}:){1,4}(?::[0-9a-fA-F]{1,4}){1,3}|(?:[0-9a-fA-F]{1,4}:){1,3}(?::[0-9a-fA-F]{1,4}){1,4}|(?:[0-9a-fA-F]{1,4}:){1,2}(?::[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:(?:(?::[0-9a-fA-F]{1,4}){1,6})|:(?:(?::[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(?::[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(?:ffff(:0{1,4}){0,1}:){0,1}(?:(?:25[0-5]|(?:2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(?:25[0-5]|(?:2[0-4]|1{0,1}[0-9]){0,1}[0-9])|(?:[0-9a-fA-F]{1,4}:){1,4}:(?:(?:25[0-5]|(?:2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(?:25[0-5]|(?:2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\]
Couple of things to note:
- this is executed in Java, "" is the escape character, so when there’s multiple "" together, I assume that at some point all will be replaced by just 1 ""
- when you print by console \u0080 and \uFFFF in java, both produces invalid characters, I don’t know why are part of the regex