diff options
author | Flaviu Tamas <tamasflaviu@gmail.com> | 2015-01-17 22:45:23 -0500 |
---|---|---|
committer | Flaviu Tamas <tamasflaviu@gmail.com> | 2015-01-17 22:45:23 -0500 |
commit | 447d0e0e8b7f3126ddbf21b44a3d182978805dfe (patch) | |
tree | f56059d77cba935e1e577b9da63cf481fbf267e1 /src/nre.nim | |
parent | 4d25a89ba990b602fdf19b1174a3eba180482029 (diff) | |
download | Nim-447d0e0e8b7f3126ddbf21b44a3d182978805dfe.tar.gz |
Add more typical string replace
Diffstat (limited to 'src/nre.nim')
-rw-r--r-- | src/nre.nim | 4 |
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 ) |