Well, simplest is to use one of the many regex classes out there, failing that....
8<----------8<----------8<----------8<----------8<----------8<----------8<----------8<---------- var test = "Some link http://test.com and another http://www.berty.co.uklets test."; var markedUp = ""; var h = test.split("http://"); var idx = test.indexOf("http://"); var i = idx == 0 ? 0 : 1; if(idx != -1) { for(; i<h.length; i++) { var t = h[i].split(" "); var href = t[0]; var r = ""; if(t.length > 1) { href = t.shift(); r = t.join(" "); } h[i] = "<a href=\"http://" + href + "\">" + href + "</a> " + r; } markedUp = h.join(""); } else markedUp = test; trace(markedUp); 8<----------8<----------8<----------8<----------8<----------8<----------8<----------8<---------- On 6/26/07, Mick G <[EMAIL PROTECTED]> wrote:
Can anyone think of an efficient way to convert a URL (or multiple URLs) in a string to a link. eg. myString = "this website http://www.this.com is really cool"; would convert to: "this website <a href='http://www.this.com'> http://www.this.com</a> is really cool. I tried splitting the string at "http://" the splitting that again at a space and... anyway, no luck here :) Any help appreciated. _______________________________________________ [email protected] To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
_______________________________________________ [email protected] To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com

