regex

The regular expression that an EmailAddress should match.

The underlying pattern is ^\S+@\S+\.\S+$.

Here's the explanation associated to each symbol used in this regular expression:

  • ^ Beginning. Matches the beginning of the string, or the beginning of a line if the multiline flag (m) is enabled.

  • \S Not whitespace. Matches any character that is not a whitespace character (spaces, tabs, line breaks).

  • + Quantifier. Match 1 or more of the preceding token.

  • @ Character. Matches a "@" character (char code 64).

  • \. Escaped character. Matches a "." character (char code 46).

  • $ End. Matches the end of the string, or the end of a line if the multiline flag (m) is enabled.


Calling from Kotlin

Here's an example of calling this property from Kotlin code:

println(EmailAddress.regex) // ^\S+@\S+\.\S+$

Calling from Java

Here's an example of calling this property from Java code:

final Regex regex = EmailAddress.Companion.getRegex();
System.out.println(regex); // ^\S+@\S+\.\S+$