[REBOL] replacing urls in html using parse function...
From: jean::holzammer::faedv-n::bayern::de at: 2-Sep-2002 9:52
Hi,
I try to replace all href and src assignments in a html document by my own
using the parse function.
Here are my attempts (step by step) so far. Look at the one but last
function call. It seems the parser is not at the right position after
replacing the first url. I expected it to replace all (any keyword before
rule) urls at once.
I know there are lots of parsing experts on this list. Probably just some
minor changes would be necessary.
So have a look. Thanx in advance.
Jean
a: {assas href="http://www.ann.lu" dfdfdf src="http://bla.org" fdfdf}
parse/all a [any [ [[thru {href="}] | [thru {src="}]] copy text to {"}
(print text)]]
parse/all a [any [ [[thru {href="}] | [thru {src="}]] position1: to {"}
position2: (change/part position1 "neu" position2 print position2)]]
parse/all a [any [ [[thru {href="}] | [thru {src="}]] position1: to {"}
position2: (change/part position1 "neu" position2 print position1 print
position2 print "")]]
>> a: {assas href="http://www.ann.lu" dfdfdf src="http://bla.org" fdfdf}
== {assas href="http://www.ann.lu" dfdfdf src="http://bla.org" fdfdf}
>> parse/all a [any [ [[thru {href="}] | [thru {src="}]] copy text to {"}
(print text)]]
http://www.ann.lu
http://bla.org
== false
>>
>>
>> a: {assas href="http://www.ann.lu" dfdfdf src="http://bla.org" fdfdf}
== {assas href="http://www.ann.lu" dfdfdf src="http://bla.org" fdfdf}
>> parse/all a [any [ [[thru {href="}] | [thru {src="}]] position1: to {"}
position2: (change/part position1 "neu" position2 print position2)]]
http://bla.org" fdfdf
== false
>>
>>
>> a: {assas href="http://www.ann.lu" dfdfdf src="http://bla.org" fdfdf}
== {assas href="http://www.ann.lu" dfdfdf src="http://bla.org" fdfdf}
>> parse/all a [any [ [[thru {href="}] | [thru {src="}]] position1: to {"}
position2: (change/part position1 "neu" position2 print position1 print
position2
print "")]]
neu" dfdfdf src="http://bla.org" fdfdf
http://bla.org" fdfdf
== false
>>
>> a
== {assas href="neu" dfdfdf src="http://bla.org" fdfdf}
>>
>>
>> parse/all a [any [ [[thru {href="}] | [thru {src="}]] position1: to {"}
position2: (change/part position1 "neu" position2 print position1 print
position2 prin
t "")]]
neu" dfdfdf src="http://bla.org" fdfdf
dfdfdf srchttp://bla.org" fdfdf
neu" fdfdf
** Script Error: Out of range or past end
** Where: halt-view
** Near: print position2 print ""
>> a
== {assas href="neu" dfdfdf src="neu" fdfdf}