[K/N][stdlib] Fix cases with existing pattern before matched with dot quantifier interval in regular expressions implementation(^KT-49967 Fixed)
This commit is contained in:
@@ -1253,4 +1253,11 @@ class PatternTest {
|
|||||||
regex = Regex(patString, RegexOption.DOT_MATCHES_ALL)
|
regex = Regex(patString, RegexOption.DOT_MATCHES_ALL)
|
||||||
assertFalse(regex.containsMatchIn(testString))
|
assertFalse(regex.containsMatchIn(testString))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test fun testFailedFindDotQuantifier() {
|
||||||
|
val regex = Regex("For.+ \\(1\\)")
|
||||||
|
val result = regex.find("This is good (1), For You")
|
||||||
|
|
||||||
|
assertNull(result)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -97,8 +97,8 @@ internal abstract class AbstractSet(val type: Int = 0) {
|
|||||||
?: -1
|
?: -1
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param leftLimit - an index, to finish search back (left limit, inclusive).
|
* @param leftLimit - an index, to finish search back (left limit).
|
||||||
* @param rightLimit - an index to start search from (right limit, exclusive).
|
* @param rightLimit - an index to start search from (right limit).
|
||||||
* @param testString - test string.
|
* @param testString - test string.
|
||||||
* @param matchResult - match result.
|
* @param matchResult - match result.
|
||||||
* @return an index to start back search next time if this search fails(new left bound);
|
* @return an index to start back search next time if this search fails(new left bound);
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ open internal class SequenceSet(substring: CharSequence, val ignoreCase: Boolean
|
|||||||
var index = rightLimit
|
var index = rightLimit
|
||||||
while (index >= leftLimit) {
|
while (index >= leftLimit) {
|
||||||
index = testString.lastIndexOf(patternString, index, ignoreCase)
|
index = testString.lastIndexOf(patternString, index, ignoreCase)
|
||||||
if (index < 0) {
|
if (index < 0 || index < leftLimit) {
|
||||||
return -1
|
return -1
|
||||||
}
|
}
|
||||||
// Check if we have a supplementary code point at the beginning or at the end of the string.
|
// Check if we have a supplementary code point at the beginning or at the end of the string.
|
||||||
|
|||||||
Reference in New Issue
Block a user