default

@JvmName(name = "defaultPattern")
fun default(): EmailAddressRegex

Returns the default regular expression for validating email addresses, corresponding to the following pattern: ^\S+@\S+\.\S+$.


Pattern symbols

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

  • ^ 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. Match 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 function from Kotlin code:

val regex: EmailAddressRegex = EmailAddressRegex.default()
val expected = """^\S+@\S+\.\S+$"""
assertEquals(expected, "$regex")

Calling from Java

The Java method generated from this function is named defaultPattern, due to the default keyword present in this programming language.

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

final EmailAddressRegex regex = EmailAddressRegex.defaultPattern();
final String pattern = regex.toString();
final String expected = "^\\S+@\\S+\\.\\S+$";
Assertions.assertEquals(expected, pattern);