Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] Re: parse, again...

From: ryanc:iesco-dms at: 1-Nov-2001 9:17

Seems like 'thru 'end always returns false. Try it this way...
>> chars: complement charset []
== make bitset! #{ FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF }
>> html-code: [ copy tag ["<" thru ">"] | copy txt to "<" | some chars]
== [copy tag ["<" thru ">"] | copy txt to "<" | some chars]
>> parse/all read http://www.rebol.com [to "<" some html-code]
== true
>>
If you want to confirm that it is html and not just a text page, add a 'to <html> in front, otherwise you might get false positives. --Ryan Hallvard Ystad wrote:
> I seem to get something wrong. Look here: > >> html-code: [ copy tag ["<" thru ">"] | copy txt to "<" ] > == [copy tag ["<" thru ">"] | copy txt to "<"] > >> parse/all read http://www.rebol.com/ [to "<" some html-code] > connecting to: www.rebol.com > == false > > This returns false because the website ends with some whitespace after the > last tag. I redefine 'html-code and try again: > >> html-code: [ copy tag ["<" thru ">"] | copy txt [to "<" | thru end]] > == [copy tag ["<" thru ">"] | copy txt [to "<" | thru end]] > >> parse/all read http://www.rebol.com/ [to "<" some html-code] > connecting to: www.rebol.com > == false > > Hm. Why does this return false? Another try: > >> html-code: [ copy tag ["<" thru ">"] | copy txt to "<" | copy txt thru > end ] > == [copy tag ["<" thru ">"] | copy txt to "<" | copy txt thru end] > >> parse/all read http://www.rebol.com/ [to "<" some html-code] > connecting to: www.rebol.com > == false > > Still wrong return value from 'parse. But then, finally: > >> html-code: [ copy tag ["<" thru ">"] | copy txt to "<" | skip] > == [copy tag ["<" thru ">"] | copy txt to "<" | skip] > >> parse/all read http://www.rebol.com/ [to "<" some html-code] > connecting to: www.rebol.com > == true > > So I managed, finally. But what if I want to use whatever is written after > the last tag? And especially: what's wrong with my second approach? > > I know this probably is basic, and that it's probably been answered a > hundred times already on this mailing list, but I just can't seem to find > the solution (and I _have_ searched, yes). > > ~H > > Praetera censeo Carthaginem esse delendam > > -- > To unsubscribe from this list, please send an email to > [rebol-request--rebol--com] with "unsubscribe" in the > subject, without the quotes.
-- Ryan Cole Programmer Analyst www.iesco-dms.com 707-468-5400