Skip to contents

# Extract string based on regex pattern

Source: `R/str_extract.R`
`str_extract.Rd`

Use base::strsplit to

## Usage

    str_extract(d, pattern)

## Arguments

d

  vector of character strings

pattern

  regex pattern to match

## Value

vector of character strings

## Examples

    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]+)")
    #>  [1] "1"  "2"  "3"  "4"  "5"  "6"  "7"  "8"  "9"  "10" "11" "12" "13" "14" "15"
    #> [16] "16" "17" "18" "19" "20"