mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-03 03:32:32 +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.
```
(cherry picked from commit 2e3777d6f3)
This commit is contained in:
@@ -559,7 +559,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.
|
||||
##
|
||||
## .. code-block:: nim
|
||||
## for piece in "foo:bar".rsplit(':'):
|
||||
@@ -584,7 +584,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.
|
||||
##
|
||||
## .. code-block:: nim
|
||||
## for piece in "foo bar".rsplit(WhiteSpace):
|
||||
@@ -612,7 +612,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.
|
||||
##
|
||||
## .. code-block:: nim
|
||||
## for piece in "foothebar".rsplit("the"):
|
||||
@@ -789,7 +789,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.
|
||||
@@ -817,7 +817,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.
|
||||
@@ -847,7 +847,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