ADVERTISEMENT
ADVERTISEMENT

Example of containsMatchIn() function in Kotlin

Learn about the containsMatchIn() function in Kotlin, and demonstrate the example of containsMatchIn() function.
Submitted by IncludeHelp, on March 25, 2022

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

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.

Kotlin Regular Expression (Regex) Programs »


ADVERTISEMENT
ADVERTISEMENT


Comments and Discussions!



ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT

Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.