From 8ab6fa1be255e91f4a455f5e4a97aff07c12d84c Mon Sep 17 00:00:00 2001 From: Araq Date: Thu, 11 Oct 2018 16:15:16 +0200 Subject: [PATCH] fixes #9306 --- lib/impure/re.nim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/impure/re.nim b/lib/impure/re.nim index a60f708286..e621162d0d 100644 --- a/lib/impure/re.nim +++ b/lib/impure/re.nim @@ -428,7 +428,7 @@ proc replace*(s: string, sub: Regex, by = ""): string = ## "; " result = "" var prev = 0 - while true: + while prev < s.len: var match = findBounds(s, sub, prev) if match.first < 0: break add(result, substr(s, prev, match.first-1)) @@ -453,7 +453,7 @@ proc replacef*(s: string, sub: Regex, by: string): string = result = "" var caps: array[MaxSubpatterns, string] var prev = 0 - while true: + while prev < s.len: var match = findBounds(s, sub, caps, prev) if match.first < 0: break add(result, substr(s, prev, match.first-1))