summary refs log tree commit diff stats
path: root/src/nre.nim
diff options
context:
space:
mode:
Diffstat (limited to 'src/nre.nim')
-rw-r--r--src/nre.nim4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/nre.nim b/src/nre.nim
index 89680ea5d..b66a1f6da 100644
--- a/src/nre.nim
+++ b/src/nre.nim
@@ -431,3 +431,7 @@ proc replace*(str: string, pattern: Regex,
     lastIdx = bounds.b
 
   result.add(str.substr(lastIdx, str.len - 1))
+
+proc replace*(str: string, pattern: Regex, sub: string): string =
+  return str.replace(pattern, proc (match: RegexMatch): string =
+    sub % match.captures.toSeq )