summary refs log tree commit diff stats
path: root/src/nre.nim
diff options
context:
space:
mode:
authorFlaviu Tamas <tamasflaviu@gmail.com>2015-01-17 22:45:23 -0500
committerFlaviu Tamas <tamasflaviu@gmail.com>2015-01-17 22:45:23 -0500
commit447d0e0e8b7f3126ddbf21b44a3d182978805dfe (patch)
treef56059d77cba935e1e577b9da63cf481fbf267e1 /src/nre.nim
parent4d25a89ba990b602fdf19b1174a3eba180482029 (diff)
downloadNim-447d0e0e8b7f3126ddbf21b44a3d182978805dfe.tar.gz
Add more typical string replace
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 )