regExtract: Find All Substrings

Description Usage Arguments Value References Examples

View source: R/econModelSupport.R

Description

Given a string or vector of strings, find and extract all substrings that match the pattern.

Usage

1
regExtract(pattrn, x)

Arguments

pattrn

String. Regular Expression Pattern.

x

vector of Strings.

Value

vectors of found substrings

References

Regular expression to extract text between square brackets https://stackoverflow.com/questions/2403122/regular-expression-to-extract-text-between-square-brackets

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
## Not run: 
# not including the parentheses
regExtract("(?<=\\()(.*?)(?=\\))", "LIST (c1)")
[1] "c1"

regExtract("(?<=\\()(.*?)(?=\\))", "LIST (((c1)::integer))")
[1] "((c1"

RegExtract("(?<=\\()(\\w+)(?=\\))", "LIST (((c1)::integer))")
[1] "c1"

## End(Not run)

AndreMikulec/econModel documentation built on June 30, 2021, 9:48 a.m.