String replace (recognize an url and make a link)

Hi! I’m looking for some help with it…

Trying to recognize urls from an xml text (as1)
I have not access to edit the xml.
The url is loaded as string, ex: “lorem ipsum dolor sit
The url is not always at the end of the string

I’m loading it and showing as htmlText, but the url is not likeable (coz have no tags T.T )

using split and join i got:

function sar(holder, searchfor, replacement) {
    tarray = holder.split(searchfor);
    holder = tarray.join(replacement);
    return (holder);
myConvertedText = sar("lorem ipsum dolor sit", "http://", "<a href='http://");
//result:   lorem ipsum dolor sit <a href='

As the ur is not ever the last word in the string I can not add the tags at the end…

How can I get, count or recognize the end of url to add the html tags?

any help is very welcome…