Add captures in split
This commit is contained in:
parent
a03d178a56
commit
f88f4912c2
1 changed files with 4 additions and 0 deletions
|
|
@ -408,6 +408,10 @@ proc split*(str: string, pattern: Regex): seq[string] =
|
||||||
|
|
||||||
lastIdx = bounds.b
|
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,
|
# last match: Each match takes the previous substring,
|
||||||
# but "1 2".split(/ /) needs to return @["1", "2"].
|
# but "1 2".split(/ /) needs to return @["1", "2"].
|
||||||
# This handles "2"
|
# This handles "2"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue