summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorFlaviu Tamas <tamasflaviu@gmail.com>2015-01-15 19:53:43 -0500
committerFlaviu Tamas <tamasflaviu@gmail.com>2015-01-15 19:53:43 -0500
commitf88f4912c2ffaad81083bfcf67e8f06492ce7527 (patch)
tree8b12fc8a986cad549dc285fa5a3660603ea3dc92
parenta03d178a561e50259465ba8b8e9972fad73e9dbc (diff)
downloadNim-f88f4912c2ffaad81083bfcf67e8f06492ce7527.tar.gz
Add captures in split
-rw-r--r--src/nre.nim4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/nre.nim b/src/nre.nim
index 1c803f27f..3c1645456 100644
--- a/src/nre.nim
+++ b/src/nre.nim
@@ -408,6 +408,10 @@ proc split*(str: string, pattern: Regex): seq[string] =
 
     lastIdx = bounds.b
 
+    for cap in match.captures:
+      # if there are captures, include them in the result
+      result.add(cap)
+
   # last match: Each match takes the previous substring,
   # but "1 2".split(/ /) needs to return @["1", "2"].
   # This handles "2"