Rename Regex.hasMatch to containsMatchIn, and add corresponding contains function to CharSequence.
This commit is contained in:
@@ -59,12 +59,15 @@ public class Regex(pattern: String, options: Set<RegexOption>) {
|
||||
return match != null && (match as RegExpMatch).index == 0 && nativePattern.lastIndex == input.length()
|
||||
}
|
||||
|
||||
/** Indicates whether the regular expression can find at least a match in the specified [input]. */
|
||||
public fun hasMatch(input: CharSequence): Boolean {
|
||||
/** Indicates whether the regular expression can find at least one match in the specified [input]. */
|
||||
public fun containsMatchIn(input: CharSequence): Boolean {
|
||||
nativePattern.reset()
|
||||
return nativePattern.test(input.toString())
|
||||
}
|
||||
|
||||
@Deprecated("Use containsMatchIn() or 'in' operator instead.", ReplaceWith("this in input"))
|
||||
public fun hasMatch(input: CharSequence): Boolean = containsMatchIn(input)
|
||||
|
||||
/** Returns the first match of a regular expression in the [input], beginning at the specified [startIndex].
|
||||
*
|
||||
* @param startIndex An index to start search with, by default 0. Must be not less than zero and not greater than `input.length()`
|
||||
|
||||
Reference in New Issue
Block a user