Q:

Example of containsMatchIn() function in Kotlin

0

containsMatchIn() Function

The containsMatchIn() function is used to check whether there exists any match of our pattern in the input and returns a boolean value.

Syntax:

fun containsMatchIn(input: CharSequence): Boolean

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Kotlin program to demonstrate the example of containsMatchIn() function

// Example of containsMatchIn() function
fun main()
{
	// Regex to match any string starting with 'i'
	val pattern = Regex("^i")
    
	println(pattern.containsMatchIn("includehelp"))
	println(pattern.containsMatchIn("Incognito"))
}

Output:

true
false

Explanation:

The first string ("includehelp") starts with "i" and the second string ("Incognito") starts with "I". Thus, the output is true and false.

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Example of find() function in Kotlin... >>