R Under development (unstable) (2023-11-07 r85491 ucrt) -- "Unsuffered Consequences" Copyright (C) 2023 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > ## > ## r e g e x p . R Test suite > ## > > > regexp <- pracma::regexp > regexpi <- pracma::regexpi > regexprep <- pracma::regexprep > refindall <- pracma::refindall > > s <- "bat cat can car COAT court cut ct CAT-scan" > pat <- 'c[aeiou]+t' > identical(regexp(s, pat)$match, + c("cat", "cut")) [1] TRUE > identical(regexpi(s, pat)$match, + c("cat", "COAT", "cut", "CAT")) [1] TRUE > identical(regexp(s, pat, once = TRUE)$match, + c("cat")) [1] TRUE > identical(regexp(s, pat, ignorecase = TRUE, split = TRUE)$split, + c("bat ", " can car ", " court ", " ct ", "-scan")) [1] TRUE > > identical(regexprep(s, pat, '---'), + c("bat --- can car COAT court --- ct CAT-scan")) [1] TRUE > identical(regexprep(s, pat, '---', once = TRUE), + c("bat --- can car COAT court cut ct CAT-scan")) [1] TRUE > identical(regexprep(s, pat, '---', ignorecase = TRUE), + c("bat --- can car --- court --- ct ----scan")) [1] TRUE > > identical(refindall("AbababaBa", 'aba'), c(3, 5)) [1] TRUE > identical(refindall("AbababaBa", 'aba', ignorecase = TRUE), c(1, 3, 5, 7)) [1] TRUE > > proc.time() user system elapsed 0.12 0.04 0.15