Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
* New `str_split_1()` is tailored for the special case of splitting up a single
string (#409).

* New `str_split_i()` extract a single piece from a string (#278, @bfgray3).
* New `str_split_i()` extracts a single piece from a string (#278, @bfgray3).

* New `str_like()` allows the use of SQL wildcards (#280, @rjpat).

Expand All @@ -103,7 +103,7 @@
* It no longer requires a pattern so you can use it to display strings with
special characters.
* It highlights unusual whitespace characters.
* It's vectorised over both string` and `pattern` (#407).
* It's vectorised over both `string` and `pattern` (#407).
* It defaults to displaying all matches, making `str_view_all()` redundant
(and hence deprecated) (#455).

Expand All @@ -117,10 +117,10 @@

* A new data source for `sentences` has fixed many small errors.

* `str_extract()` and `str_exctract_all()` now work correctly when `pattern`
* `str_extract()` and `str_extract_all()` now work correctly when `pattern`
is a `boundary()`.

* `str_flatten()` gains a `last` argument that optionally override the
* `str_flatten()` gains a `last` argument that optionally overrides the
final separator (#377). It gains a `na.rm` argument to remove missing
values (since it's a summary function) (#439).

Expand All @@ -137,15 +137,15 @@
`whitespace_only = FALSE` to return to the previous behaviour (#335, @rjpat).

* `word()` now returns all the sentence when using a negative `start` parameter
that is greater or equal than the number of words. (@pdelboca, #245)
that is greater than or equal to the number of words. (@pdelboca, #245)

# stringr 1.4.1

Hot patch release to resolve R CMD check failures.

# stringr 1.4.0

* `str_interp()` now renders lists consistently independent on the presence of
* `str_interp()` now renders lists consistently independently of the presence of
additional placeholders (@amhrasmussen).

* New `str_starts()` and `str_ends()` functions to detect patterns at the
Expand Down Expand Up @@ -191,7 +191,7 @@ Hot patch release to resolve R CMD check failures.
(@Shians, #178)

* `str_squish()` removes spaces from both the left and right side of strings,
and also converts multiple space (or space-like characters) to a single
and also converts multiple spaces (or space-like characters) to a single
space within strings (@stephlocke, #197).

* `str_sub()` gains `omit_na` argument for ignoring `NA`. Accordingly,
Expand Down Expand Up @@ -235,7 +235,7 @@ Hot patch release to resolve R CMD check failures.

* `str_replace_all()` now throws an error if `replacement` is not a character
vector. If `replacement` is `NA_character_` it replaces the complete string
with replaces with `NA` (#124).
with `NA` (#124).

* All functions that take a locale (e.g. `str_to_lower()` and `str_sort()`)
default to "en" (English) to ensure that the default is consistent across
Expand Down Expand Up @@ -280,7 +280,7 @@ Hot patch release to resolve R CMD check failures.
your string processing needs, I highly recommend looking at stringi in more
detail.

* stringr gains a vignette, currently a straight forward update of the article
* stringr gains a vignette, currently a straightforward update of the article
that appeared in the R Journal.

* `str_c()` now returns a zero length vector if any of its inputs are
Expand Down Expand Up @@ -323,7 +323,7 @@ Hot patch release to resolve R CMD check failures.

# stringr 0.6.2

* fixed path in `str_wrap` example so works for more R installations.
* fixed path in `str_wrap` example so it works for more R installations.

* remove dependency on plyr

Expand All @@ -345,7 +345,7 @@ Hot patch release to resolve R CMD check failures.
* new `str_wrap` function which gives `strwrap` output in a more convenient
format

* new `word` function extract words from a string given user defined
* new `word` function extracts words from a string given user defined
separator (thanks to suggestion by David Cooper)

* `str_locate` now returns consistent type when matching empty string (thanks
Expand Down
8 changes: 4 additions & 4 deletions R/c.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#' vector. It's very similar to [paste0()] but uses tidyverse recycling and
#' `NA` rules.
#'
#' One way to understand how `str_c()` works is picture a 2d matrix of strings,
#' One way to understand how `str_c()` works is to picture a 2d matrix of strings,
#' where each argument forms a column. `sep` is inserted between each column,
#' and then each row is combined together into a single string. If `collapse`
#' is set, it's inserted between each row, and then the result is again
Expand All @@ -21,8 +21,8 @@
#' be missing. Use [dplyr::coalesce()] or [str_replace_na()] to convert to
#' the desired value.
#' @param sep String to insert between input vectors.
#' @param collapse Optional string used to combine output into single
#' string. Generally better to use [str_flatten()] if you needed this
#' @param collapse Optional string used to combine output into a single
#' string. Generally better to use [str_flatten()] if you need this
#' behaviour.
#' @return If `collapse = NULL` (the default) a character vector with
#' length equal to the longest input. If `collapse` is a string, a character
Expand All @@ -41,7 +41,7 @@
#' # Missing inputs give missing outputs
#' str_c(c("a", NA, "b"), "-d")
#' paste0(c("a", NA, "b"), "-d")
#' # Use str_replace_NA to display literal NAs:
#' # Use str_replace_na to display literal NAs:
#' str_c(str_replace_na(c("a", NA, "b")), "-d")
#'
#' # Uses tidyverse recycling rules
Expand Down
6 changes: 3 additions & 3 deletions R/case.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
#' * `str_to_lower()` converts to lower case.
#' * `str_to_title()` converts to title case, where only the first letter of
#' each word is capitalized.
#' * `str_to_sentence()` convert to sentence case, where only the first letter
#' of sentence is capitalized.
#' * `str_to_sentence()` converts to sentence case, where only the first letter
#' of each sentence is capitalized.
#'
#' @inheritParams str_detect
#' @inheritParams coll
Expand Down Expand Up @@ -121,7 +121,7 @@ to_words <- function(string) {
"(?<=\\p{L})(?=\\p{N})",
# number followed by letter
"(?<=\\p{N})(?=\\p{L})",
# uppercase followed uppercase then lowercase (i.e. end of acronym)
# uppercase followed by uppercase then lowercase (i.e. end of acronym)
"(?<=\\p{Lu})(?=\\p{Lu}\\p{Ll})",
sep = "|"
)
Expand Down
6 changes: 3 additions & 3 deletions R/count.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#' Count number of matches
#'
#' Counts the number of times `pattern` is found within each element
#' of `string.`
#' of `string`.
#'
#' @inheritParams str_detect
#' @param pattern Pattern to look for.
Expand All @@ -21,8 +21,8 @@
#' @return An integer vector the same length as `string`/`pattern`.
#' @seealso [stringi::stri_count()] which this function wraps.
#'
#' [str_locate()]/[str_locate_all()] to locate position
#' of matches
#' [str_locate()]/[str_locate_all()] to locate the position
#' of matches.
#'
#' @export
#' @examples
Expand Down
2 changes: 1 addition & 1 deletion R/data.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#' written by Gabor Csardi; the data was collected by Darius Kazemi
#' and made available at \url{https://github.com/dariusk/corpora}.
#' `sentences` is a collection of "Harvard sentences" used for
#' standardised testing of voice.
#' standardized testing of voice.
#'
#' @format Character vectors.
#' @name stringr-data
Expand Down
4 changes: 2 additions & 2 deletions R/detect.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#' 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.
#' You cannot 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 All @@ -36,7 +36,7 @@
#' # Also vectorised over pattern
#' str_detect("aecfg", letters)
#'
#' # Returns TRUE if the pattern do NOT match
#' # Returns TRUE if the pattern does NOT match
#' str_detect(fruit, "^p", negate = TRUE)
str_detect <- function(string, pattern, negate = FALSE) {
check_lengths(string, pattern)
Expand Down
4 changes: 2 additions & 2 deletions R/equal.R
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#' Determine if two strings are equivalent
#'
#' This uses Unicode canonicalisation rules, and optionally ignores case.
#' This uses Unicode canonicalization rules, and optionally ignores case.
#'
#' @param x,y A pair of character vectors.
#' @inheritParams str_order
#' @param ignore_case Ignore case when comparing strings?
#' @return An logical vector the same length as `x`/`y`.
#' @return A logical vector the same length as `x`/`y`.
#' @seealso [stringi::stri_cmp_equiv()] for the underlying implementation.
#' @export
#' @examples
Expand Down
4 changes: 2 additions & 2 deletions R/escape.R
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#' Escape regular expression metacharacters
#'
#' This function escapes metacharacter, the characters that have special
#' This function escapes metacharacters, the characters that have special
#' meaning to the regular expression engine. In most cases you are better
#' off using [fixed()] since it is faster, but `str_escape()` is useful
#' if you are composing user provided strings into a pattern.
#' if you are composing user-provided strings into a pattern.
#'
#' @inheritParams str_detect
#' @return A character vector the same length as `string`.
Expand Down
4 changes: 2 additions & 2 deletions R/flatten.R
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#' Flatten a string
#
#'
#' @description
#' `str_flatten()` reduces a character vector to a single string. This is a
#' summary function because regardless of the length of the input `x`, it
#' always returns a single string.
#'
#' `str_flatten_comma()` is a variation designed specifically for flattening
#' with commas. It automatically recognises if `last` uses the Oxford comma
#' with commas. It automatically recognizes if `last` uses the Oxford comma
#' and handles the special case of 2 elements.
#'
#' @inheritParams str_detect
Expand Down
4 changes: 2 additions & 2 deletions R/glue.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#' `glue_data()` directly from glue for more control.
#'
#' @inheritParams glue::glue
#' @return A character vector with same length as the longest input.
#' @return A character vector with the same length as the longest input.
#' @export
#' @examples
#' name <- "Fred"
Expand All @@ -24,7 +24,7 @@
#' # single braces can be inserted by doubling them
#' str_glue("My name is {name}, not {{name}}.")
#'
#' # You can also used named arguments
#' # You can also use named arguments
#' str_glue(
#' "My name is {name}, ",
#' "and my age next year is {age + 1}.",
Expand Down
22 changes: 10 additions & 12 deletions R/interp.R
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ str_interp <- function(string, env = parent.frame()) {
}
}

#' Match String Interpolation Placeholders
#' Match string interpolation placeholders
#'
#' Given a character string a set of expression placeholders are matched. They
#' Given a character string, a set of expression placeholders is matched. They
#' are of the form \code{${...}} or optionally \code{$[f]{...}} where `f`
#' is a valid format for [sprintf()].
#'
Expand Down Expand Up @@ -117,8 +117,6 @@ interp_placeholders <- function(string, error_call = caller_env()) {
# Identify the positions within the parts of the matching closing braces.
# These are the lengths of the placeholder matches.
lengths <- mapply(match_brace, opens, closes)

# Update the `starts` match data with the
attr(starts, "match.length") <- lengths

# Return both the indices (regex match data) and the actual placeholder
Expand All @@ -129,7 +127,7 @@ interp_placeholders <- function(string, error_call = caller_env()) {
)
}

#' Evaluate String Interpolation Matches
#' Evaluate string interpolation matches
#'
#' The expression part of string interpolation matches are evaluated in a
#' specified environment and formatted for replacement in the original string.
Expand Down Expand Up @@ -162,7 +160,7 @@ eval_interp_matches <- function(matches, env, error_call = caller_env()) {
mapply(sprintf, formats, values, SIMPLIFY = FALSE)
}

#' Extract Expression Objects from String Interpolation Matches
#' Extract expression objects from string interpolation matches
#'
#' An interpolation match object will contain both its wrapping \code{${ }} part
#' and possibly a format. This extracts the expression parts and parses them to
Expand Down Expand Up @@ -198,11 +196,11 @@ extract_expressions <- function(matches, error_call = caller_env()) {
}


#' Extract String Interpolation Formats from Matched Placeholders
#' Extract string interpolation formats from matched placeholders
#'
#' An expression placeholder for string interpolation may optionally contain a
#' format valid for [sprintf()]. This function will extract such or
#' default to "s" the format for strings.
#' format valid for [sprintf()]. This function extracts such formats, or
#' defaults to `"s"`, the format for strings.
#'
#' @param matches Match data
#'
Expand All @@ -218,7 +216,7 @@ extract_formats <- function(matches) {
paste0("%", ifelse(formats == "", "s", formats))
}

#' Utility Function for Matching a Closing Brace
#' Utility function for matching a closing brace
#'
#' Given positions of opening and closing braces `match_brace` identifies
#' the closing brace matching the first opening brace.
Expand All @@ -227,15 +225,15 @@ extract_formats <- function(matches) {
#'
#' @param closing integer: Vector with positions of closing braces.
#'
#' @return Integer with the posision of the matching brace.
#' @return Integer with the position of the matching brace.
#'
#' @noRd
#' @author Stefan Milton Bache
match_brace <- function(opening, closing) {
# maximum index for the matching closing brace
max_close <- max(closing)

# "path" for mapping opening and closing breaces
# "path" for mapping opening and closing braces
path <- numeric(max_close)

# Set openings to 1, and closings to -1
Expand Down
4 changes: 2 additions & 2 deletions R/locate.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#' gives the position at the start of the match, and the second column, `end`,
#' gives the position of the end.
#'
#'* `str_locate_all()` returns a list of integer matrices with the same
#' * `str_locate_all()` returns a list of integer matrices with the same
#' length as `string`/`pattern`. The matrices have columns `start` and `end`
#' as above, and one row for each match.
#' @seealso
Expand Down Expand Up @@ -99,7 +99,7 @@ str_locate_all <- function(string, pattern) {
#' previously matched.
#'
#' @param loc matrix of match locations, as from [str_locate_all()]
#' @return numeric match giving locations of non-matches
#' @return numeric matrix giving locations of non-matches
#' @export
#' @examples
#' numbers <- "1 and 2 and 4 and 456"
Expand Down
6 changes: 3 additions & 3 deletions R/match.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@
#' named, `(?<name>pattern)` capture groups.
#'
#' Use a non-capturing group, `(?:pattern)`, if you need to override default
#' operate precedence but don't want to capture the result.
#' operator precedence but don't want to capture the result.
#'
#' @inheritParams str_detect
#' @param pattern Unlike other stringr functions, `str_match()` only supports
#' regular expressions, as described `vignette("regular-expressions")`.
#' regular expressions, as described in `vignette("regular-expressions")`.
#' The pattern should contain at least one capturing group.
#' @return
#' * `str_match()`: a character matrix with the same number of rows as the
#' length of `string`/`pattern`. The first column is the complete match,
#' followed by one column for each capture group. The columns will be named
#' if you used "named captured groups", i.e. `(?<name>pattern')`.
#' if you used "named capture groups", i.e. `(?<name>pattern)`.
#'
#' * `str_match_all()`: a list of the same length as `string`/`pattern`
#' containing character matrices. Each matrix has columns as described above
Expand Down
Empty file added R/ord.R
Empty file.
2 changes: 1 addition & 1 deletion R/pad.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#' @param pad Single padding character (default is a space).
#' @param use_width If `FALSE`, use the length of the string instead of the
#' width; see [str_width()]/[str_length()] for the difference.
#' @return A character vector the same length as `stringr`/`width`/`pad`.
#' @return A character vector the same length as `string`/`width`/`pad`.
#' @seealso [str_trim()] to remove whitespace;
#' [str_trunc()] to decrease the maximum width of a string.
#' @export
Expand Down
Empty file added R/rap.R
Empty file.
4 changes: 2 additions & 2 deletions R/replace.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
#' 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.
#' You cannot 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`.
#' but it can be a vector the same length as `string` or `pattern`.
#' References of the form `\1`, `\2`, etc will be replaced with
#' the contents of the respective matched group (created by `()`).
#'
Expand Down
Loading
Loading