glob2rx {sfsmisc} | R Documentation |
Change wildcard aka globbing (or “ls” like)
pattern into the corresponding regular expression (regexp
).
glob2rx(pattern)
pattern |
character vector |
a character vector of the same length as the input pattern
where the “wild card” is translated to the corresponding
regular expression.
Martin Maechler, Unix/sed based version, 1991; current: 2004
regexp
about regular expression,
sub
, etc about substitutions using regexps.
stopifnot(glob2rx("abc.*") == "^abc\\.", glob2rx("a?b.*") == "^a.b\\.", glob2rx("*.doc") == "^.*\\.doc$", glob2rx("*.t*") == "^.*\\.t", glob2rx("*.t??") == "^.*\\.t..$")