orThrow
Returns a regular expression for validating email addresses from the specified pattern, or throws an IllegalArgumentException if the pattern doesn't match the default one.
Calling from Kotlin
Here's an example of calling this function from Kotlin code:
EmailAddressRegex.orThrow("""^[a-z]+@[a-z]+\.[a-z]+$""")
Content copied to clipboard
Calling from Java
Here's an example of calling this function from Java code:
EmailAddressRegex.orThrow("^\\S+@\\S+\\.\\S+$");
Content copied to clipboard
See the orNull function for returning null
in case of invalid pattern instead of throwing an exception.