Description Usage Arguments Value Source Examples
View source: R/regcapturedmatches.R
regcapturedmatches.R: extracts captured matches from match data obtained by regexpr, gregexpr or regexec.
1 | regcapturedmatches(x, m)
|
x |
(A list of) strings. |
m |
Parsed data, a result from a regular expression function. |
A list with captured matches
The coded adapted from: regcapturedmatches.R on gist.github.com answer on stackoverflow.com. Originally written by: MrFlick
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | # usage
x <- c("larry:35,M", "alison:22,F", "dave", "lily:55,F")
m <- regexpr("(.*):(\\d+),([MF])", x, perl = TRUE)
rez <- regcapturedmatches(x, m)
rez
regexp2df(x, "(.*):(\\d+),([MF])")
m <- regexpr("(?<name>.*):(?<age>\\d+),(?<gender>[MF])",
x,
perl = TRUE)
rez2 <- regcapturedmatches(x, m)
rez2
regexp2df(x, "(?<name>.*):(?<age>\\d+),(?<gender>[MF])")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.