From f88f4912c2ffaad81083bfcf67e8f06492ce7527 Mon Sep 17 00:00:00 2001 From: Flaviu Tamas <tamasflaviu@gmail.com> Date: Thu, 15 Jan 2015 19:53:43 -0500 Subject: Add captures in split --- src/nre.nim | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/nre.nim') 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" -- cgit 1.4.1-2-gfad0