Skip to content

Commit

Permalink
Fix documentation that implies pattern argument can be empty (#563)
Browse files Browse the repository at this point in the history
Fixes #508

Co-authored by: @RobLBaker
Co-authored-by: Hadley Wickham <[email protected]>
  • Loading branch information
wright13 authored Aug 20, 2024
1 parent be893c1 commit 12839fc
Show file tree
Hide file tree
Showing 16 changed files with 31 additions and 30 deletions.
14 changes: 14 additions & 0 deletions R/count.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,20 @@
#' of `string.`
#'
#' @inheritParams str_detect
#' @param pattern Pattern to look for.
#'
#' The default interpretation is a regular expression, as described in
#' `vignette("regular-expressions")`. Use [regex()] for finer control of the
#' matching behaviour.
#'
#' Match a fixed string (i.e. by comparing only bytes), using
#' [fixed()]. This is fast, but approximate. Generally,
#' for matching human text, you'll want [coll()] which
#' respects character matching rules for the specified locale.
#'
#' Match character, word, line and sentence boundaries with
#' [boundary()]. The empty string, `""``, is equivalent to
#' `boundary("character")`.
#' @return An integer vector the same length as `string`/`pattern`.
#' @seealso [stringi::stri_count()] which this function wraps.
#'
Expand Down
4 changes: 1 addition & 3 deletions R/detect.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@
#' for matching human text, you'll want [coll()] which
#' respects character matching rules for the specified locale.
#'
#' Match character, word, line and sentence boundaries with
#' [boundary()]. An empty pattern, "", is equivalent to
#' `boundary("character")`.
#' You can not match boundaries, including `""`, with this function.
#'
#' @param negate If `TRUE`, inverts the resulting boolean vector.
#' @return A logical vector the same length as `string`/`pattern`.
Expand Down
2 changes: 1 addition & 1 deletion R/extract.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#' `str_extract()` extracts the first complete match from each string,
#' `str_extract_all()`extracts all matches from each string.
#'
#' @inheritParams str_detect
#' @inheritParams str_count
#' @param group If supplied, instead of returning the complete match, will
#' return the matched text from the specified capturing group.
#' @seealso [str_match()] to extract matched groups;
Expand Down
2 changes: 1 addition & 1 deletion R/locate.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#' Because the `start` and `end` values are inclusive, zero-length matches
#' (e.g. `$`, `^`, `\\b`) will have an `end` that is smaller than `start`.
#'
#' @inheritParams str_detect
#' @inheritParams str_count
#' @returns
#' * `str_locate()` returns an integer matrix with two columns and
#' one row for each element of `string`. The first column, `start`,
Expand Down
2 changes: 2 additions & 0 deletions R/replace.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
#' [fixed()]. This is fast, but approximate. Generally,
#' for matching human text, you'll want [coll()] which
#' respects character matching rules for the specified locale.
#'
#' You can not match boundaries, including `""`, with this function.
#' @param replacement The replacement value, usually a single string,
#' but it can be the a vector the same length as `string` or `pattern`.
#' References of the form `\1`, `\2`, etc will be replaced with
Expand Down
1 change: 0 additions & 1 deletion R/split.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
#' * `str_split_fixed()` splits each string in a character vector into a
#' fixed number of pieces, returning a character matrix.
#'
#' @inheritParams str_detect
#' @inheritParams str_extract
#' @param n Maximum number of pieces to return. Default (Inf) uses all
#' possible split positions.
Expand Down
3 changes: 1 addition & 2 deletions man/str_count.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions man/str_detect.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions man/str_extract.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions man/str_locate.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions man/str_remove.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion man/str_replace.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions man/str_split.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions man/str_subset.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions man/str_view.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions man/str_which.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 12839fc

Please sign in to comment.