Learn R Programming

miscset (version 0.4)

gregexprind: Pattern Matching and Extraction

Description

Function to extract a certain index from gregexpr().

Usage

gregexprind(pattern, text, n, ...)

Arguments

pattern
Character string containing a regular expression to be searched in text.
text
Character vector where the search is performed.
n
Numeric value or character string "last" to extract nth or last position of pattern in each value of text.
...
Arguments passed to function gregexpr().

Value

  • Numeric vector of length length(text).

Details

See ?gregexpr for further information on arguments. See ?"regular expression" for the use of regular expressions.

See Also

gregexpr, regular expression (regex)

Examples

Run this code
#

gregexprind(c("a"),c("abab","ab","xyz",NA), 1)
gregexprind(c("a"),c("abab","ab","xyz",NA), 2)
gregexprind(c("a"),c("abab","ab","xyz",NA), "last")

#

Run the code above in your browser using DataLab