1
0
mirror of https://github.com/msberends/AMR.git synced 2025-07-10 23:01:58 +02:00

(v1.2.0.9023) ab_from_text() improvement

This commit is contained in:
2020-07-02 21:12:52 +02:00
parent 298e67a45b
commit 152ac5bcad
29 changed files with 175 additions and 118 deletions

View File

@ -102,14 +102,19 @@ like <- function(x, pattern, ignore.case = TRUE) {
as.integer(x) %in% base::grep(pattern, levels(x), ignore.case = FALSE, fixed = fixed)
} else {
tryCatch(base::grepl(pattern, x, ignore.case = FALSE, fixed = fixed),
error = function(e) ifelse(grepl("Invalid regexp", e$message),
# try with perl = TRUE:
return(base::grepl(pattern = pattern, x = x,
ignore.case = FALSE,
fixed = fixed,
perl = TRUE)),
# stop otherwise
stop(e$message)))
error = function(e) {
if (grepl("invalid reg(ular )?exp", e$message, ignore.case = TRUE)) {
# try with perl = TRUE:
return(base::grepl(pattern = pattern,
x = x,
ignore.case = FALSE,
fixed = fixed,
perl = TRUE))
} else {
# stop otherwise
stop(e$message)
}
})
}
}