Thanks for your comments and suggestions so far. I don't have the luxury of knowing where the URLs are in the user comments.
Here's some sample output:
Here's some sample code. I made it easy by using URL "markers" <l> and </l>. I've been playing around with URL location using regex to avoid having to use these markers. If anyone has a good regular expression for finding URLs let me know. I'm having varied success with what I've found on the net so far.
// link markup example
text = "Periarthritis is defined as: Inflammation of the tissues around a joint. " ||
"<l>http://www.reference.md/files/D010/mD010489.html</l> As arthralgia, myalgia, tendonitis " ||
"and other musculoskeletal issues are listed events, periarthritis can be considered listed as well.
Comment: no good sentinel case — not a new signal; one case also reported somnolence and " ||
"another case reported “yawny” which could mean sleepy *<l>http://www.ncbi.nlm.nih.gov/pubmed/12530994</l>";
text_list = {};
link_list = {};
keep_going = 1;
istart = 1;
linkstart = "<l>";
linkend = "</l>";
text_len = length(text);
i = 0;
while(keep_going,
start_pos = contains(text, linkstart, istart);
if (start_pos,
end_pos = contains(text, linkend, istart);
if (end_pos,
i++;
text_list[i] = substr(text, istart, (start_pos - istart));
link_list[i] = substr(text, start_pos + 3, (end_pos - start_pos - 3));
istart = istart + end_pos - istart + 4;
);
);
if (!start_pos,
i++;
text_list[i] = substr(text, istart);
keep_going = 0;
);
);
tb = {};
lb = {};
nt = nitems(text_list);
nw = new window("Test link",
vb = vlistbox(
)
);
for(i = 1, i <= nt, i++,
tb[i] = text box(text_list[i], << set width(400));
vb << append(tb[i]);
if (i < nt,
one_button = evalinsert("\[lb[i] = button box("^link_list[i]^", web("^link_list[i]^"), << underline style(1) )]\");
eval(parse(one_button));
vb << append(lb[i]);
);
);