Converting relative URLs to absolute URLs with regex
Today I was working on an app in which the menu had to be built using a HTML editor. And sure enough, half of the URLs that were supposed to be absolute were not. Luckily, it's fairly easy to fix that with a regex search/replace.
Here's the regex to search for:
href="(?!http)
This look for any string starting with href=", followed by any string that does NOT start with 'http'.
Then just replace all occurances with:
href="http://www.yourdomain.com/
And Bob's your uncle!
Pro tip: a great Mac app to test your regular expressions with is Patterns.