Sed regex keep matched pattern

I had a problem where I had to match specific lines in a file and append characters in front of the line.

Regular see works like this:

$ head dates1.txt | sed 's/^[0-9][0-9]\./,[0-9][0-9]/'
,[0-9][0-9]04.2011
vj,30.06.2011
,[0-9][0-9]06.2011
,[0-9][0-9]09.2011
,[0-9][0-9]05.2011
vj,03.05.2011
2.vpj,21.04.2011

The problem here is sed replacing its match.

The fix is to use & character in regex string (I found the solution from here.

$ head dates1.txt | sed 's/^[0-9][0-9]\./,&/' 
,20.04.2011
vj,30.06.2011
,30.06.2011
,15.09.2011
,03.05.2011
vj,03.05.2011
2.vpj,21.04.2011

Clojure: open URL with enlive in specific encoding

I wanted to open html file and process it with enlive.

My first attempt to read the file content to a variable named ‘dom’:

(def dom (net.cgrand.enlive-html/html-resource "test.html"))

This works but the encoding was wrong (my html file has iso8859-1 encoding).

I did a bit of searching and ended up using this:

(def dom
  (-> "file:///path/to/file/testi.html" ;<- clojure threading macro
      java.net.URL.
      .getContent (java.io.InputStreamReader. "iso8859-1") ;<- encoding goes here
      net.cgrand.enlive-html/html-resource))

Now I have properly working html reading with proper encoding.

Tips for understanding Clojure threading macro can be found here: http://blog.fogus.me/2009/09/04/understanding-the-clojure-macro/