toString

override fun toString(): String

Returns the string representation of this regular expression.


Calling from Kotlin

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

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

Calling from Java

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

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