Today I came up with this: (defn locate-lines [regexp] (let [pattern (. java.util.regex.Pattern (compile regexp (. java.util.regex.Pattern CASE_INSENSITIVE)))] (debug (str "pattern: " pattern)) (with-open r (new java.io.LineNumberReader (new java.io.FileReader "some_large_file.txt")) (binding [*in* r] (loop [line (read-line) acc nil] (if line (if (. (. pattern (matcher line)) (find)) (recur (read-line) (if acc (cons (list (. r (getLineNumber)) line) acc) (list (list (. r (getLineNumber)) line)))) (recur (read-line) acc)) (reverse acc)))))))
It works well and on my PC it takes a few seconds to search through a file 140000 lines big and return matches. Can I do something to make it faster? I actually don't need the line numbers although I thought I would. Thanks! /Mathias --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~----------~----~----~----~------~----~------~--~---