This commit is contained in:
Araq 2018-10-11 16:15:16 +02:00
commit 8ab6fa1be2

View file

@ -428,7 +428,7 @@ proc replace*(s: string, sub: Regex, by = ""): string =
## "; " ## "; "
result = "" result = ""
var prev = 0 var prev = 0
while true: while prev < s.len:
var match = findBounds(s, sub, prev) var match = findBounds(s, sub, prev)
if match.first < 0: break if match.first < 0: break
add(result, substr(s, prev, match.first-1)) add(result, substr(s, prev, match.first-1))
@ -453,7 +453,7 @@ proc replacef*(s: string, sub: Regex, by: string): string =
result = "" result = ""
var caps: array[MaxSubpatterns, string] var caps: array[MaxSubpatterns, string]
var prev = 0 var prev = 0
while true: while prev < s.len:
var match = findBounds(s, sub, caps, prev) var match = findBounds(s, sub, caps, prev)
if match.first < 0: break if match.first < 0: break
add(result, substr(s, prev, match.first-1)) add(result, substr(s, prev, match.first-1))