Learn R Programming

miscset (version 1.0.0)

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).

See Also

See gregexpr for further information on arguments. See regex for the use of regular expressions.

Examples

Run this code
#

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

#

Run the code above in your browser using DataLab