From e027ea91395b27849c4b8db11555a263ea894b76 Mon Sep 17 00:00:00 2001
From: Flaviu Tamas <tamasflaviu@gmail.com>
Date: Sat, 24 Jan 2015 14:58:09 -0500
Subject: Add start to split

---
 src/nre.nim | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

(limited to 'src/nre.nim')

diff --git a/src/nre.nim b/src/nre.nim
index 47e374978..6743a82dc 100644
--- a/src/nre.nim
+++ b/src/nre.nim
@@ -384,13 +384,13 @@ proc renderBounds(str: string, bounds: Slice[int]): string =
   for i in bounds.a .. bounds.b:
     result.add("^")
 
-proc split*(str: string, pattern: Regex, maxSplit = -1): seq[string] =
+proc split*(str: string, pattern: Regex, maxSplit = -1, start = 0): seq[string] =
   result = @[]
-  var lastIdx = 0
+  var lastIdx = start
   var splits = 0
   var bounds: Slice[int]
 
-  for match in str.findIter(pattern):
+  for match in str.findIter(pattern, start = start):
     # upper bound is exclusive, lower is inclusive:
     #
     # 0123456
@@ -401,7 +401,7 @@ proc split*(str: string, pattern: Regex, maxSplit = -1): seq[string] =
     # "12".split("") would be @["", "1", "2"], but
     # if we skip an empty first match, it's the correct
     # @["1", "2"]
-    if bounds.a < bounds.b or bounds.a > 0:
+    if bounds.a < bounds.b or bounds.a > start:
       result.add(str.substr(lastIdx, bounds.a - 1))
       splits += 1
 
-- 
cgit 1.4.1-2-gfad0