Others

Phone Number

pattern = "([0-9]+)-([0-9]+)-([0-9]+)"
regexp = re2(pattern)
string = "650-253-0001"
autoplot(microbenchmark(
      TRE = grepl(pattern, string),
      PCRE = grepl(pattern, string, perl=TRUE),
      ICU = stri_detect_regex(string, pattern),
      RE2n =  re2_detect(string, pattern),
      RE2c = re2_detect(string, regexp)
    ))

HTTP

http_text =
  "GET /asdfhjasdhfasdlfhasdflkjasdfkljasdhflaskdjhfalksdjfhasdlkfhasdlkjfhasdljkfhadsjklf HTTP/1.1"

pattern = "(?-s)^(?:GET|POST) +([^ ]+) HTTP"
regexp = re2(pattern)

autoplot(microbenchmark(
      ICU = stri_match(http_text, regex = pattern),
      RE2n =  re2_match(http_text, pattern),
      RE2c = re2_match(http_text, regexp)
))


Try the re2r package in your browser

Any scripts or data that you put into this service are public.

re2r documentation built on May 2, 2019, 12:35 p.m.