Posts Tagged ‘Regular Expressions’

Reformat URLs with Javascript and Regular Expressions

Friday, March 6th, 2009

As part of the Chatterbloc project we had a requirement to do a couple of things:

  1. Reformat www. links with http://www.
  2. Replace http:// strings with an HTML A link equivalent

Surprisingly I found it pretty hard to find a hard and fast solution for this that had already been done, so I either wasn’t looking properly, or it doesn’t exist. Anyway, I created two functions for this piece of work, I’ll show you those, and also how to use them.

(more…)