strMultiMatch: return the actual matches from a bracketed regex

Description Usage Arguments Value

View source: R/util.R

Description

Be careful: this may throw funny results for exotic regex, but so far, it seems okay. it also drops the first result which always seems to be a duplicate or whole-string match.

strPaitMatch differs in that there should only be two pairs of parenthesis, then the first (by default) becomes the name, and the second the value.

Usage

1
2
3
4
strMultiMatch(pattern, text, dropEmpty = FALSE, ...)

strPairMatch(pattern, text, swap = FALSE, dropEmpty = FALSE, pos = c(1,
  2), ...)

Arguments

pattern

regular expression: if it has bracketed sections, these submatches are returned

text

is the string to match against. This vector should be the same length as the pattern vector, or the patern vector should be length one.

dropEmpty

logical whether to drop rows with no matches

...

are additional parameters passed to regexec and regmatches. I haven't tried this: it may need two separate variables containing lists of params, since this will send everything to both functions.

swap

logical scalar, whether to swap the names and values. Default is not to swap, so the first match becomes the name.

Value

list of character vectors, list length being the length of the inptu text vector.


jackwasey/icd9 documentation built on May 18, 2019, 7:57 a.m.