Kotlin program to demonstrate the example of find() function
// Example of find() function
fun main()
{
// Regex to match "oo" in a string
val pattern = Regex("oo")
val res : MatchResult? = pattern.find("noncooperations coordination", 2)
println(res ?.value)
val res1 : MatchResult? = pattern.find("noncooperations coordination", 20)
println(res1 ?.value)
}
Output:
oo
null
Explanation:
In the first statement "oo" is there from the index 2, but in the second statement "oo" is not there from the index 20.
Kotlin program to demonstrate the example of find() function
Output:
Explanation:
In the first statement "oo" is there from the index 2, but in the second statement "oo" is not there from the index 20.
need an explanation for this answer? contact us directly to get an explanation for this answer