Skip to content

A regex interpreter.

License

Apache-2.0, Unknown licenses found

Licenses found

Apache-2.0
LICENSE
Unknown
LICENSE.txt
Notifications You must be signed in to change notification settings

SFurnace/CZ-Regex

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CZ-Regex

A interpreter for regex search, just for learning.

How to use

parse-regex (-> string? any/c)

parse a regex struct from string, for example:

(parse-regex "(a|b|c)")
;;=>
;;(Choice
;; `(,(Sequence
;;     `(,(Group
;;         (Choice
;;          `(,(Sequence `(#\a))
;;            ,(Sequence `(#\b))
;;            ,(Sequence `(#\c))))
;;         false
;;         false)))))

(parse-regex "[^a-z_]{1,2}")
;;=>
;;(Choice
;; `(,(Sequence
;;     `(,(Repeat (Range `((#\a . #\z) #\_) true) 1 2 true)))))

match-regex (->* (any/c string?) (natural-number/c) (or/c string? false/c))

match string with given regex, for example:

(let ([r (parse-regex "http://([a-zA-Z0-9_]+\\.?)+(/.*?)(\\?[^ ]+)")]
      [str "http://www.bilibili.com/some/path?some=query   rest"])
  (match-regex r str))
;;=>
;;"http://www.bilibili.com/some/path?some=query"

About

A regex interpreter.

Resources

License

Apache-2.0, Unknown licenses found

Licenses found

Apache-2.0
LICENSE
Unknown
LICENSE.txt

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages