Changelog

link Icon changelog.com

Frak takes an entirely different approach to generating regular expressions

logged by @logbot 2013-08-15T13:54:31Z permalink

Hot on the heals of our Verbal Expressions coverage comes Frak by Joel Holdbrooks.

Frak also generates regular expressions for you, but it does it in a completely different way. With Frak, you don't write an expression to match string patterns. Instead, you give it a set of strings and it generates an expression which matches them.

Frak is written in Clojure, so you install it by adding a dependency to your project.clj file:

[frak "0.1.2"]

To use it, simply require it, pass it a collection of strings, and it will return the resulting regular expression:

user> (require 'frak)
nil
user> (frak/pattern ["foo" "bar" "baz" "quux"])
#"(?:ba[rz]|foo|quux)"
user> (frak/pattern ["Clojure" "Clojars" "ClojureScript"])
#"Cloj(?:ure(?:Script)?|ars)"

Check out the README to learn how it works, see some benchmarks, and get frak'in!

If you have an opinion share it on Hacker News.

0:00 / 0:00