re2(pattern, utf_8 = TRUE, case_sensitive = TRUE, posix_syntax = FALSE, dot_nl = FALSE, literal = FALSE, longest_match = FALSE, never_nl = FALSE, never_capture = FALSE, one_line = FALSE, perl_classes = FALSE, word_boundary = FALSE, log_error = FALSE, max_mem = 8388608, simplify = TRUE)
Create a pre-compiled regular expression from a string.
The max_mem option controls how much memory can be used to hold the compiled form of the regexp (the Prog) and its cached DFA graphs.
Once a DFA fills its budget, it flushes its cache and starts over. If this happens too often, RE2 falls back on the NFA implementation.
For now, make the default budget something close to Code Search.
Default maxmem = 8<<20 = 8388608;
regexp = re2("test") regexpre2 pre-compiled regular expression pattern: test number of capturing subpatterns: 0 capturing names with indices: .match expression size: 8re2_match("abc\ndef","(?s)(.*)").match .1 [1,] "abc\ndef" "abc\ndef"re2_match("abc\ndef", re2("(?s)(.*)", never_nl = TRUE)).match .1 [1,] "abc" "abc"re2_detect("\n", re2(".", dot_nl = TRUE))[1] TRUEre2_detect("\n", ".")[1] FALSEget_number_of_groups(re2("(A)(v)",never_capture = TRUE))[1] 0re2_match("aaabaaaa",re2("(a|aaa)",longest_match = TRUE)).match .1 [1,] "aaa" "aaa"re2_match("aaabaaaa",re2("(a|aaa)",longest_match = FALSE)).match .1 [1,] "a" "a"re2_match("a+b", re2("a+b", literal = TRUE)).match [1,] "a+b"re2_detect("abc" , re2("abc", posix_syntax = TRUE))[1] TRUEre2("(?P<name>re)")re2 pre-compiled regular expression pattern: (?P<name>re) number of capturing subpatterns: 1 capturing names with indices: .match name expression size: 8## Not run: # # expect_error(re2("(?P<name>re)", posix_syntax = TRUE)) # ## End(Not run)