Take caution when advancing to the next match after an empty string was matched not to stuck at the same position.

This commit is contained in:
Ilya Gorbunov
2015-04-23 18:04:50 +03:00
parent 260553d516
commit aa6bdb039b
3 changed files with 4 additions and 4 deletions
+1 -1
View File
@@ -188,6 +188,6 @@ private fun RegExp.findNext(input: String, from: Int): MatchResult? {
override fun get(index: Int): MatchGroup? = match[index]?.let { MatchGroup(it) }
}
override fun next(): MatchResult? = this@findNext.findNext(input, range.end + 1)
override fun next(): MatchResult? = this@findNext.findNext(input, if (range.isEmpty()) range.start + 1 else range.end + 1)
}
}