Adding specific text in a string using Regular expressions

Hi

I have some long html text like this:

some text http://www.example.com continue of the text

How can I add some content before and after the matching statement. I meant for example how can I change the above text into:

some text <a href="http://www.example.com">http://www.example.com</a> continue of the text

thanks

There are some complex cases to allow for when doing this.

Here is a good linkify script that does a good job at handling these issues.