Learn R Programming

stRoke (version 23.9.1)

str_extract: Extract string based on regex pattern

Description

Use base::strsplit to

Usage

str_extract(d, pattern)

Value

vector of character strings

Arguments

d

vector of character strings

pattern

regex pattern to match

Examples

Run this code
ls <- do.call(c,lapply(sample(4:8,20,TRUE),function(i){
paste(sample(letters,i,TRUE),collapse = "")}))
ds <- do.call(c,lapply(1:20,function(i){
paste(sample(ls,1),i,sample(ls,1),"23",sep = "_")}))
str_extract(ds,"([0-9]+)")

Run the code above in your browser using DataLab