{"size": 1627, "ext": "rktl", "max_stars_repo_path": "racket/src/cs/demo/regexp.rktl", "max_stars_repo_name": "lkh01/racket", "max_stars_repo_stars_event_min_datetime": "2018-07-29T04:13:52.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-14T16:11:17.000Z", "max_issues_repo_path": "racket/src/cs/demo/regexp.rktl", "max_issues_repo_name": "lkh01/racket", "max_issues_repo_issues_event_min_datetime": "2017-08-25T20:26:37.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-26T17:48:40.000Z", "max_forks_repo_path": "racket/src/cs/demo/regexp.rktl", "max_forks_repo_name": "lkh01/racket", "max_forks_repo_forks_event_min_datetime": "2016-04-25T11:47:57.000Z", "max_forks_repo_forks_event_max_datetime": "2017-05-09T14:52:48.000Z"}
{"max_stars_count": 10, "max_issues_count": 15, "max_forks_count": 3, "avg_line_length": 31.2884615385, "max_line_length": 67, "alphanum_fraction": 0.3755377996}
(define (check pat str)
  (write
   (time
    (let ([rx (byte-regexp (string->bytes/utf-8 pat))]
          [in (string->bytes/utf-8 str)])
      (let loop ([v #f] [n 100000])
        (if (zero? n)
            v
            (loop (regexp-match rx in)
                  (sub1 n)))))))
  (newline))

;; A smallish backtracking test, more or less:
(check "ab(?:a*c)*d" "abaacacaaacacaaacd")

;; Relatively realitic workload:
(define ipv6-hex "[0-9a-fA-F:]*:[0-9a-fA-F:]*")
(define url-s
  (string-append
   "^"
   "(?:"              ; / scheme-colon-opt
   "([^:/?#]*)"       ; | #1 = scheme-opt
   ":)?"              ; \
   "(?://"            ; / slash-slash-authority-opt
   "(?:"              ; | / user-at-opt
   "([^/?#@]*)"       ; | | #2 = user-opt
   "@)?"              ; | \
   "(?:"              ;
   "(?:\\["           ; | / #3 = ipv6-host-opt
   "(" ipv6-hex ")"   ; | | hex-addresses
   "\\])|"            ; | \
   "([^/?#:]*)"       ; | #4 = host-opt
   ")?"               ;
   "(?::"             ; | / colon-port-opt
   "([0-9]*)"         ; | | #5 = port-opt
   ")?"               ; | \
   ")?"               ; \
   "([^?#]*)"         ; #6 = path
   "(?:\\?"           ; / question-query-opt
   "([^#]*)"          ; | #7 = query-opt
   ")?"               ; \
   "(?:#"             ; / hash-fragment-opt
   "(.*)"             ; | #8 = fragment-opt
   ")?"               ; \
   "$"))
(define rlo "https://racket-lang.org:80x/people.html?check=ok#end")
(check url-s rlo)

;; A test of scanning a byte string to look for the letter "b"
;; (where a tight loop in C is likely to win):
(check "a*b" (make-string 1024 #\a))
