str_grep: Return elements matching a pattern

Description Usage Arguments Details See Also Examples

View source: R/str_grep.R

Description

Get elements matching (str_grep) or not matching (str_grep) a pattern.

Usage

1
2
3
str_grep(string, pattern)

str_grepv(string, pattern)

Arguments

string

string ; Input vector. Either a character vector, or something coercible to one.

pattern

match pattern; The default interpretation is a regular expression, as described in stringi-search-regex. Control options with regex(). Match a fixed string (i.e. by comparing only bytes), using fixed(x). This is fast, but approximate. Generally, for matching human text, you'll want coll(x) 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").

Details

str_grep returnes elements matching a pattern. Shorthand for string[ str_detect(string,pattern) ]

str_grepv returnes elements that do not matching a pattern. The 'v' derived from the unix flag -v from the linux grep command. It is mostly as a convenient way to avoid negative lookaheads.

See Also

str_detect

Examples

1
2
 str_grep( letters, '[aeiou]' )
 str_grepv( letters[1:5], '[aeiou]' )

decisionpatterns/stringr.tools documentation built on Nov. 4, 2019, 10:24 a.m.