Thank you, I am aware that there are packages that can accomplish this. I 
mentioned stringr::str_extract as a function that does not drop empty matches. 
I think that the behavior of regmatches(..., regexpr(...)) in base R should 
permit an option to prevent dropping of empty matches both for sake of 
consistency with the rest of the language (missing data does not yield a 
dropped index in other sorts of R functions, and an empty match conceptually 
corresponds with missing data) and facility of use in data.frames. The behavior 
of regmatches(..., gregexpr(...)) is not objectionable to me, as lists do not 
drop indices when they contain character(0) vectors. Alternatively, perhaps 
this should be reflected in the (currently non-exported) strextract.

Best,
CG

______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

Reply via email to