pmatchSafe('ap', c('apples', 'oranges', 'bananas'))
pmatchSafe('AP', c('apples', 'oranges', 'bananas'))
pmatchSafe('AP', c('apples', 'oranges', 'bananas'),
ignoreCase = FALSE, error = FALSE)
pmatchSafe(c('ba', 'ap'), c('apples', 'oranges', 'bananas'))
# No match:
tryCatch(
pmatchSafe('kumquats', c('apples', 'oranges', 'bananas')),
error = function(cond) FALSE
)
pmatchSafe('kumquats', c('apples', 'oranges', 'bananas'), error = FALSE)
pmatchSafe(c('ap', 'corn'), c('apples', 'oranges', 'bananas'), error = FALSE)
# Too many matches:
tryCatch(
pmatchSafe(c('ap', 'ba'), c('apples', 'oranges', 'bananas'), nmax = 1),
error=function(cond) FALSE
)
Run the code above in your browser using DataLab