This Rust implementation of regular expressions guarantees linear time performance.
It can handle both untrusted regular expressions and untrusted search text.
subject <- paste(rep("a", N), collapse="")
pattern <- paste(rep(c("a?", "a"), each=N), collapse="")
Rust >= 1.8
devtools::install_github("rustr/rsegex")
library(rsegex)
reg = regex("a")
re_match(reg, c("aa","b","aasdads"))
#> [1] TRUE FALSE TRUE
reg = regex("(?P<last>[^,\\s]+),\\s+(?P<first>\\S+)")
input = "Springsteen, Bruce"
re_replace(reg, input, "$first $last")
#> [1] "Bruce Springsteen"
reg = regex("[ \\t]+")
re_split(reg, c("a b c d e","sd ssd s"))
#> [[1]]
#> [1] "a" "b" "c" "d" "e"
#>
#> [[2]]
#> [1] "sd" "ssd" "s"
reg = regex("(?x)
(?P<year>\\d{4}) # the year
-
(?P<month>\\d{2}) # the month
-
(?P<day>\\d{2}) # the day
")
captures_len(reg)
#> [1] 4
captures_names(reg)
#> [1] "" "year" "month" "day"
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.