mirror of
https://github.com/nim-lang/Nim.git
synced 2025-12-29 09:24:36 +00:00
strutils: improve doc comments for replace funcs (#17427)
This commit fixes mispellings of "occurrence" introduced by: -76a3b350ce(#17337) -8e8bea9044(#17339) and adds the same "every occurrence of" in the `replaceWord` func. Other changes: - Prefer "replace with" to "replace by". - Be more consistent with "the" - prefer "of the character" given that we wrote "by the character". - Try to be more consistent with writing the types - add "the string `sub`" given that we wrote "the character `sub`".
This commit is contained in:
@@ -2037,7 +2037,7 @@ func contains*(s: string, chars: set[char]): bool =
|
||||
|
||||
func replace*(s, sub: string, by = ""): string {.rtl,
|
||||
extern: "nsuReplaceStr".} =
|
||||
## Replaces every occurence of `sub` in `s` by the string `by`.
|
||||
## Replaces every occurrence of the string `sub` in `s` with the string `by`.
|
||||
##
|
||||
## See also:
|
||||
## * `find func<#find,string,string,Natural,int>`_
|
||||
@@ -2079,7 +2079,8 @@ func replace*(s, sub: string, by = ""): string {.rtl,
|
||||
|
||||
func replace*(s: string, sub, by: char): string {.rtl,
|
||||
extern: "nsuReplaceChar".} =
|
||||
## Replaces every occurence of character `sub` in `s` by the character `by`.
|
||||
## Replaces every occurrence of the character `sub` in `s` with the character
|
||||
## `by`.
|
||||
##
|
||||
## Optimized version of `replace <#replace,string,string,string>`_ for
|
||||
## characters.
|
||||
@@ -2097,7 +2098,7 @@ func replace*(s: string, sub, by: char): string {.rtl,
|
||||
|
||||
func replaceWord*(s, sub: string, by = ""): string {.rtl,
|
||||
extern: "nsuReplaceWord".} =
|
||||
## Replaces `sub` in `s` by the string `by`.
|
||||
## Replaces every occurrence of the string `sub` in `s` with the string `by`.
|
||||
##
|
||||
## Each occurrence of `sub` has to be surrounded by word boundaries
|
||||
## (comparable to `\b` in regular expressions), otherwise it is not
|
||||
|
||||
Reference in New Issue
Block a user