matches At
Требования к платформе и версии: Common (1.7), JS (1.7), JVM (1.7), Native (1.7), Wasm-JS (1.8), Wasm-WASI (1.8)
expect fun matchesAt(input: CharSequence, index: Int): Boolean
Проверяет, соответствует ли регулярное выражение части указанной символьной последовательности input точно по указанному index.
В отличие от функции matches, она не требует, чтобы совпадение распространялось до конца input.
Выбрасывает
Примеры
import kotlin.test.*
fun main() {
//sampleStart
val releaseText = "Kotlin 1.5.30 is released!"
val versionRegex = "\\d[.]\\d[.]\\d+".toRegex()
println(versionRegex.matchesAt(releaseText, 0)) // false
println(versionRegex.matchesAt(releaseText, 7)) // true
//sampleEnd
}
© 2010–2026 JetBrains s.r.o. and Kotlin Programming Language contributors
Licensed under the Apache License, Version 2.0.
https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.text/-regex/matches-at.html