mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-05 04:27:44 +00:00
Improve strutils.rsplit doc, proc and iterator have oppose result order. (#23570)
[`rsplit iterator`](https://nim-lang.org/docs/strutils.html#rsplit.i,string,char,int) yields substring in reversed order, while [`proc rsplit`](https://nim-lang.org/docs/strutils.html#rsplit%2Cstring%2Cchar%2Cint)'s order is not reversed, but its doc only declare ``` The same as the rsplit iterator, but is a func that returns a sequence of substrings. ```
This commit is contained in:
@@ -565,7 +565,7 @@ iterator rsplit*(s: string, sep: char,
|
||||
maxsplit: int = -1): string =
|
||||
## Splits the string `s` into substrings from the right using a
|
||||
## string separator. Works exactly the same as `split iterator
|
||||
## <#split.i,string,char,int>`_ except in reverse order.
|
||||
## <#split.i,string,char,int>`_ except in **reverse** order.
|
||||
##
|
||||
## ```nim
|
||||
## for piece in "foo:bar".rsplit(':'):
|
||||
@@ -592,7 +592,7 @@ iterator rsplit*(s: string, seps: set[char] = Whitespace,
|
||||
maxsplit: int = -1): string =
|
||||
## Splits the string `s` into substrings from the right using a
|
||||
## string separator. Works exactly the same as `split iterator
|
||||
## <#split.i,string,char,int>`_ except in reverse order.
|
||||
## <#split.i,string,char,int>`_ except in **reverse** order.
|
||||
##
|
||||
## ```nim
|
||||
## for piece in "foo bar".rsplit(WhiteSpace):
|
||||
@@ -622,7 +622,7 @@ iterator rsplit*(s: string, sep: string, maxsplit: int = -1,
|
||||
keepSeparators: bool = false): string =
|
||||
## Splits the string `s` into substrings from the right using a
|
||||
## string separator. Works exactly the same as `split iterator
|
||||
## <#split.i,string,string,int>`_ except in reverse order.
|
||||
## <#split.i,string,string,int>`_ except in **reverse** order.
|
||||
##
|
||||
## ```nim
|
||||
## for piece in "foothebar".rsplit("the"):
|
||||
@@ -805,7 +805,7 @@ func split*(s: string, sep: string, maxsplit: int = -1): seq[string] {.rtl,
|
||||
func rsplit*(s: string, sep: char, maxsplit: int = -1): seq[string] {.rtl,
|
||||
extern: "nsuRSplitChar".} =
|
||||
## The same as the `rsplit iterator <#rsplit.i,string,char,int>`_, but is a func
|
||||
## that returns a sequence of substrings.
|
||||
## that returns a sequence of substrings in original order.
|
||||
##
|
||||
## A possible common use case for `rsplit` is path manipulation,
|
||||
## particularly on systems that don't use a common delimiter.
|
||||
@@ -835,7 +835,7 @@ func rsplit*(s: string, seps: set[char] = Whitespace,
|
||||
maxsplit: int = -1): seq[string]
|
||||
{.rtl, extern: "nsuRSplitCharSet".} =
|
||||
## The same as the `rsplit iterator <#rsplit.i,string,set[char],int>`_, but is a
|
||||
## func that returns a sequence of substrings.
|
||||
## func that returns a sequence of substrings in original order.
|
||||
##
|
||||
## A possible common use case for `rsplit` is path manipulation,
|
||||
## particularly on systems that don't use a common delimiter.
|
||||
@@ -867,7 +867,7 @@ func rsplit*(s: string, seps: set[char] = Whitespace,
|
||||
func rsplit*(s: string, sep: string, maxsplit: int = -1): seq[string] {.rtl,
|
||||
extern: "nsuRSplitString".} =
|
||||
## The same as the `rsplit iterator <#rsplit.i,string,string,int,bool>`_, but is a func
|
||||
## that returns a sequence of substrings.
|
||||
## that returns a sequence of substrings in original order.
|
||||
##
|
||||
## A possible common use case for `rsplit` is path manipulation,
|
||||
## particularly on systems that don't use a common delimiter.
|
||||
|
||||
Reference in New Issue
Block a user