Allow to use Regex matches CharSequence and CharSequence matches Regex in infix form
#KT-14279
This commit is contained in:
@@ -677,7 +677,7 @@ public inline fun CharSequence.replaceFirst(regex: Regex, replacement: String):
|
||||
* Returns `true` if this char sequence matches the given regular expression.
|
||||
*/
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun CharSequence.matches(regex: Regex): Boolean = regex.matches(this)
|
||||
public inline infix fun CharSequence.matches(regex: Regex): Boolean = regex.matches(this)
|
||||
|
||||
/**
|
||||
* Implementation of [regionMatches] for CharSequences.
|
||||
|
||||
@@ -116,7 +116,7 @@ internal constructor(private val nativePattern: Pattern) {
|
||||
public val options: Set<RegexOption> = fromInt(nativePattern.flags())
|
||||
|
||||
/** Indicates whether the regular expression matches the entire [input]. */
|
||||
public fun matches(input: CharSequence): Boolean = nativePattern.matcher(input).matches()
|
||||
public infix fun matches(input: CharSequence): Boolean = nativePattern.matcher(input).matches()
|
||||
|
||||
/** Indicates whether the regular expression can find at least one match in the specified [input]. */
|
||||
public fun containsMatchIn(input: CharSequence): Boolean = nativePattern.matcher(input).find()
|
||||
|
||||
Reference in New Issue
Block a user