Hi Patrick
I'm no expert like Gregg so I couldn't figure out how to use parse to
achieve what you wanted. So I wrote this simple function that may help.
I haven't tested it fully but hope it helps.
Regards
Peter
highlight-link: func [
{Wraps an <a href> tag around http urls in a string.}
text [string!]
"The string containing http urls."
/local
url-end
"Used to workout where the url ends"
][
until
[
text: find text "http:" ;; find a url
if text ;; "http:" found
[
;; find char after
url
url-end: copy find/tail text "http:"
until
[
url-end: next url-end
any
[
(url-end = "")
(#" " = first url-end)
(#"," = first url-end)
(#":" = first url-end)
(#";" = first url-end)
]
]
;; insert the <a> tag
either url-end = "" ;; url is at end
of text
[
insert text rejoin
[
{<a href="}
copy text
{">}
]
insert text: tail text "</a>"
][ ;; text after
url
url-end: first url-end
insert text rejoin
[
{<a href="}
copy/part text find text url-end
{">}
]
text: find/tail text {">} ;; skip over insert
text: find text url-end
insert text "</a>"
]
text = none
]
text: head text
]
]
--
To unsubscribe from the list, just send an email to
lists at rebol.com with unsubscribe as the subject.