Regular expressions
Posted by gregster on 30 Apr 2009 in R & D, Activity log
I had cause to build a static page of links from a directory listing, and used Text Wrangler and grep to do it.
From an initial directory listing I got a bunch of stuff that looked like this:
link-01.html
url_03.html
href9.html
I'm sure there's a one-pass method for this, but I did it in two.
First pass: prepend text with <a href="
Second pass:
Find (^.*")(.*)(\.html)
Replace with \1\2\3">\2</a>
Receive <a href="link-01.html>link-01.html</a>