Regex.matchAt/matchesAt #KT-34021
This commit is contained in:
committed by
teamcityserver
parent
d99d25e51e
commit
28a0698463
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
package kotlin.text
|
||||
@@ -143,6 +143,18 @@ internal constructor(private val nativePattern: Pattern) : Serializable {
|
||||
*/
|
||||
public actual fun matchEntire(input: CharSequence): MatchResult? = nativePattern.matcher(input).matchEntire(input)
|
||||
|
||||
@SinceKotlin("1.5")
|
||||
@ExperimentalStdlibApi
|
||||
public actual fun matchAt(input: CharSequence, index: Int): MatchResult? =
|
||||
nativePattern.matcher(input).useAnchoringBounds(false).useTransparentBounds(true).region(index, input.length).run {
|
||||
if (lookingAt()) MatcherMatchResult(this, input) else null
|
||||
}
|
||||
|
||||
@SinceKotlin("1.5")
|
||||
@ExperimentalStdlibApi
|
||||
public actual fun matchesAt(input: CharSequence, index: Int): Boolean =
|
||||
nativePattern.matcher(input).useAnchoringBounds(false).useTransparentBounds(true).region(index, input.length).lookingAt()
|
||||
|
||||
/**
|
||||
* Replaces all occurrences of this regular expression in the specified [input] string with specified [replacement] expression.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user