Skip to content
/ regex Public

a regex DSL for those who prefer verbose composable regexes to terse ones

Notifications You must be signed in to change notification settings

cgrand/regex

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

net.cgrand.regex is a Clojure notation (DSL) for regexes.

Regexes are already a DSL of their own but a write-only DSL.

This DSL allows to reuse regexes or parts of them and also adds support for named groups.

This project started as a toy/lab for the DSL course at Conj Labs Brussels back in June 2010.

Example

  (def datestamp-re
    (let [d {\0 \9}]
      (regex [d d d d :as :year] \- [d d :as :month] \- [d d :as :day])))
      
  regex=> (exec datestamp-re "2007-10-23")
  {:day "23", :month "10", :year "2007", nil "2007-10-23"}
  regex=> (exec datestamp-re "20X7-10-23")
  nil

License

Copyright © 2010-2013 Christophe Grand

Distributed under the Eclipse Public License, the same as Clojure.

About

a regex DSL for those who prefer verbose composable regexes to terse ones

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published