diff options
author | Flaviu Tamas <tamasflaviu@gmail.com> | 2015-01-15 19:53:43 -0500 |
---|---|---|
committer | Flaviu Tamas <tamasflaviu@gmail.com> | 2015-01-15 19:53:43 -0500 |
commit | f88f4912c2ffaad81083bfcf67e8f06492ce7527 (patch) | |
tree | 8b12fc8a986cad549dc285fa5a3660603ea3dc92 /src/nre.nim | |
parent | a03d178a561e50259465ba8b8e9972fad73e9dbc (diff) | |
download | Nim-f88f4912c2ffaad81083bfcf67e8f06492ce7527.tar.gz |
Add captures in split
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 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" |