Skip to content

Instantly share code, notes, and snippets.

@yPhil-gh
Created August 25, 2013 12:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yPhil-gh/6333714 to your computer and use it in GitHub Desktop.
Save yPhil-gh/6333714 to your computer and use it in GitHub Desktop.
Trying to code my own regexp generator using the wonderfulesque [frak](https://github.com/noprompt/frak) lib
(ns regard.core)
(require 'frak)
(defn -main
"I don't do a whole lot."
[& args])
(defn print-prompt []
(print "patterns to search> ")
(flush))
(defn ask-for-input []
(print-prompt)
(let [x (str (read-line))]
(println (str "User input: " x))
(println "vector output : %s" (frak/pattern (vector x)))
(println "hard-coded output : %s" (frak/pattern ["foo" "bar" "baz" "quux"]))))
(ask-for-input)
@yPhil-gh
Copy link
Author

Yields the following output :

$ lein trampoline run
patterns to search> "foo" "bar" "baz" "quux"
User input: "foo" "bar" "baz" "quux"
vector output : %s #""foo" "bar" "baz" "quux""
hard-coded output : %s #"(?:ba[rz]|foo|quux)"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment