Skip to content

Commit

Permalink
ignore perl in regexec() if the arg is not available
Browse files Browse the repository at this point in the history
  • Loading branch information
yihui committed Aug 2, 2024
1 parent a8e752b commit e820753
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,11 @@ if (!exists('gregexec', baseenv(), inherits = TRUE)) match_all = function(x, r,
# regexec() + regmatches() to match the regex once and capture substrings
match_one = function(x, r, ...) regmatches(x, regexec(r, x, ...))

# ignore the perl argument for regexec() if it's not supported (in R < 3.3); we
# use perl = TRUE only for speed in this package
if (!'perl' %in% names(formals(regexec)))
regexec = function(..., perl) base::regexec(...)

# gregexpr() + regmatches() to match full strings but not substrings in regex groups
match_full = function(x, r, ...) regmatches(x, gregexpr(r, x, ...))

Expand Down

0 comments on commit e820753

Please sign in to comment.