[REBOL] Re: Parse problem
From: Patrick::Philipot::laposte::net at: 9-Oct-2005 9:12
Hi Peter,
Thank you for pointing out the duplicate problem. I have found an easy
way to get rid of it.
first I remove the duplicate with :
bs: unique bs
Then I replace all accurrences with replace/all.
So the final draft is :
>> s: {Go see http://www.me.org, it is
{ fabulous. Really http://www.me.org is awesome!
{ And http://aaa.mypicture.com with my photos}
== {Go see http://www.me.org, it is
fabulous. Really http://www.me.org is awesome!
And http://aaa.mypicture.com with my photos}
>>
>> bs: parse s none
== ["Go" "see" "http://www.me.org" "it" "is" "fabulous." "Really" "http://www.me.org"
"is" "awesome!" "And" "http://
aaa.mypicture.c...
>>
>> remove-each w bs [not parse to-block w [url!]]
== ["http://www.me.org" "http://www.me.org" "http://aaa.mypicture.com"]
>>
>> bs: unique bs
== ["http://www.me.org" "http://aaa.mypicture.com"]
>>
>> foreach w bs [
[ replace/all find s w w rejoin [{<a=href"} w {">} w {</a>}]
[ ]
== {<a=href"http://aaa.mypicture.com">http://aaa.mypicture.com</a> with my photos}
>>
>> print s
Go see <a=href"http://www.me.org">http://www.me.org</a>, it is
fabulous. Really <a=href"http://www.me.org">http://www.me.org</a> is awesome!
And <a=href"http://aaa.mypicture.com">http://aaa.mypicture.com</a> with my photos
>>
Sometimes Rebol is so fun. I wish I had more time to play with it.
--
Ciao
Patrick