- ## fails multiply if prefix contains regexp metacharacters
- matches <- apropos(sprintf("^%s", prefix), ignore.case=FALSE)
+ literal2rx <- function(string) {
+ ## list of ERE metacharacters from ?regexp
+ gsub("([.\\|()[{^$*+?])", "\\\\\\1", string)
+ }
+ matches <- apropos(sprintf("^%s", literal2rx(prefix)), ignore.case=FALSE)