Kotlin program to demonstrate the example of matches() function
// Example of matches() function
fun main()
{
// Check entire string match
val pattern = Regex("He([ll]+)o?")
println(pattern.matches("Hello"))
println(pattern.matches("Hellllllllllllllllo"))
println(pattern.matches("HelloWorldHello"))
}
Output:
true
true
false
Explanation:
In the first two statements, strings contain the given pattern and in the third statement, the string doesn't contain the given pattern.
Kotlin program to demonstrate the example of matches() function
Output:
Explanation:
In the first two statements, strings contain the given pattern and in the third statement, the string doesn't contain the given pattern.
need an explanation for this answer? contact us directly to get an explanation for this answer