Extract text between first and last brackets
Source:R/Functions-Txt.R
extractTextBetweenBrackets.RdFunction to extract text between first and last brackets
Details
For each element in the vector, this extracts the string between the *first* "\[" and *last* "\]" from each element of the input character vector, or `NA` if no matching brackets.
Examples
# example code
extractTextBetweenBrackets("fred[x,y]=0");
#> [1] "x,y"
extractTextBetweenParens(c("fred[x,y]=0","b[z0]"));
#> [1] NA NA
extractTextBetweenParens("fred[x,y[z]]=0");
#> [1] NA