mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-02 03:02:31 +00:00
Add captures in split
This commit is contained in:
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user