extract_field: extract_field

Description Usage Arguments Examples

View source: R/tools.R

Description

This function extracts the first group of regex from a vector

Usage

1

Arguments

data

a vector of char objects

regex

character containing regular expression(s) with a group in it

Examples

1
2
3
extract_field('hello_23_node', '(\\d+)')   # '23'
extract_field(c('all-2', 'any-3', 'never-4-d'), '(\\d+)') # a vector c('2', '3', '4')
extract_field(c('all-2', 'any+3', 'never+4'), '\\+(\\d+)') # a vector c(NA, '3', '4')

etabari/ehsanr documentation built on Aug. 5, 2019, 4:07 p.m.