# from regexpr example -------------------------------------------------
# if named capture then pass names on irrespective of proto
notables <- c(" Ben Franklin and Jefferson Davis", "\tMillard Fillmore")
pattern <- "(?[[:upper:]][[:lower:]]+) (?[[:upper:]][[:lower:]]+)"
proto <- data.frame(a="", b="")
fstrcapture(notables, pattern, proto)
# from strcapture example ----------------------------------------------
# if unnamed capture then proto names used
x <- "chr1:1-1000"
pattern <- "(.*?):([[:digit:]]+)-([[:digit:]]+)"
proto <- data.frame(chr=character(), start=integer(), end=integer())
fstrcapture(x, pattern, proto)
# if no proto supplied then all captures treated as character
str(fstrcapture(x, pattern))
str(fstrcapture(x, pattern, proto))
Run the code above in your browser using DataLab