[REBOL] Fwd: Re: Re: Parse problem
From: Patrick::Philipot::laposte::net at: 8-Oct-2005 20:35
Bonjour Peter,
Thank you for your code. Being a lazy guy, I was hoping to get
advantage of block parsing. Block parsing is able to match a type, the
type being url! in my case.
Example :
>> ablock: [foo dummy http://www.me.com foo]
>> parse ablock [ some [set u url! (print u) | skip]]
http://www.me.com
So finally, my solution is :
s: {Go see http://www.me.org, it is
fabulous. And http://aaa.mypicture.com with my photos}
bs: parse s none
remove-each w bs [not parse to-block w [url!]]
foreach w bs [
replace find s w w rejoin [{<a=href"} w {">} w {</a>}]
]
print s
Go see <a=href"http://www.me.org">http://www.me.org</a>, it is
fabulous. And <a=href"http://aaa.mypicture.com">http://aaa.mypicture.com</a> with my
photos
I'm pretty sure this code is not optimized and that some guru could
make a one liner of it. Anyway it will do the job the way I like.
--
Ciao
Patrick