Add Left/Right Character(s) Boundaries

Usage

bind(..., left = "\\b", right = left, dictionary = getOption("regex.library"))

Arguments

left
A single length character vector to use as the left bound.
right
A single length character vector to use as the right bound.
dictionary
A dictionary of canned regular expressions to search within.
...
Regular expressions to add grouping parenthesis to a named expression from the default regular expression dictionary prefixed with single at (@) (e.g., "@rm_hash") or a regular expression from regex_supplement dictionary prefixed with an at (@) (e.g., "@time_12_hours").

Value

Returns a character vector.

Description

This convenience function wraps left and right boundaries of each element of a character vector. The default is to use "\b" for left and right boundaries.

Examples

bind(LETTERS, "[", "]")
[1] "\\bA\\b" "\\bB\\b" "\\bC\\b" "\\bD\\b" "\\bE\\b" "\\bF\\b" "\\bG\\b" "\\bH\\b" "\\bI\\b" "\\bJ\\b" "\\bK\\b" "\\bL\\b" [13] "\\bM\\b" "\\bN\\b" "\\bO\\b" "\\bP\\b" "\\bQ\\b" "\\bR\\b" "\\bS\\b" "\\bT\\b" "\\bU\\b" "\\bV\\b" "\\bW\\b" "\\bX\\b" [25] "\\bY\\b" "\\bZ\\b" "\\b[\\b" "\\b]\\b"
## More useful default parameters/usage x <- c("Computer is fun. Not too fun.", "No it's not, it's dumb.", "What should we do?", "You liar, it stinks!", "I am telling the truth!", "How can we be certain?", "There is no way.", "I distrust you.", "What are you talking about?", "Shall we move on? Good then.", "I'm hungry. Let's eat. You already?") Fry25 <- c("the", "of", "and", "a", "to", "in", "is", "you", "that", "it", "he", "was", "for", "on", "are", "as", "with", "his", "they", "I", "at", "be", "this", "have", "from") gsub(pastex(list(bind(Fry25))), "[[ELIM]]", x)
[1] "Computer [[ELIM]] fun. Not too fun." "No [[ELIM]]'s not, [[ELIM]]'s dumb." [3] "What should we do?" "You liar, [[ELIM]] stinks!" [5] "[[ELIM]] am telling [[ELIM]] truth!" "How can we [[ELIM]] certain?" [7] "There [[ELIM]] no way." "[[ELIM]] distrust [[ELIM]]." [9] "What [[ELIM]] [[ELIM]] talking about?" "Shall we move [[ELIM]]? Good then." [11] "[[ELIM]]'m hungry. Let's eat. You already?"

See also

paste0