2011-10-14

Emacs Lisp Exercise of the Day: extract-url

Emacs Lisp Exercise of the Day: extract-url

Here's a fun exercise: write a command “extract-url” that will extract all url in a text selection and put them in a buffer.

For example, suppose you have this text:

<div>1, <a href="iraq_pixra2.html">2</a>, <a href="http://en.wikipedia.org/wiki/Idiom">Idiom</a>, <a href="iraq_pixra3.html">3</a></div>

After calling the command, you'll get in a separate buffer this text, one url per line:

iraq_pixra2.html
http://en.wikipedia.org/wiki/Idiom
iraq_pixra3.html

You can assume that the url will always be in href="…". For extra bonus, also extract URL enclosed in single quotes: href='…'. The extracted URLs must be in the order they apppear.

I'll post a solution tomorrow.