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

Parsing problem

 [1/6] from: blackeye::subdimension::com at: 14-Nov-2002 22:19


Hello, i am new to rebol and i have a parsing problem. If somebody could help me, i'd be grateful. Here is the code : url: "www.asdfasdf.com:123/path/path/file.htm" parse/all url [ copy host [ [to ":" skip copy port to "/" ] | [ to "/"]] copy path to end ] the goal is to have the words: host = www.asdfasdf.com port = 80 path = path/path/file.htm but the host word get the value: www.asdfasdf.com:80 I tried many thins but i have now no idea of the solution. Tank you

 [2/6] from: tomc:darkwing:uoregon at: 13-Nov-2002 22:15


one way that does not use parse
>> ? url
Found these words: decode-url (function) purl (object) to-url (function) url! (datatype) url? (action)
>> u: "www.asdfasdf.com:123/path/path/file.htm"
== "www.asdfasdf.com:123/path/path/file.htm"
>> v: copy/part u find u ":"
== "www.asdfasdf.com"
>> w: decode-url u >> type? w
== object!
>> probe w
make object! [ user: none pass: none host: "123" port-id: none path: "path/path/" target: "file.htm" ] On Thu, 14 Nov 2002, Blackeye Silverseeker wrote:

 [3/6] from: carl:cybercraft at: 14-Nov-2002 19:35


On 15-Nov-02, Blackeye Silverseeker wrote:
> Hello, i am new to rebol and i have a parsing problem. If somebody > could help me, i'd be grateful. Here is the code :
<<quoted lines omitted: 8>>
> I tried many thins but i have now no idea of the solution. > Tank you
Hi, umm, Blackeye, (: Parse is probably overkill for what you're trying to do there, as there's a word (decode-url) to break up URLs into their various parts. The url does need an http:// though. Anyway, using your example, this is what decode-url gives (at the REBOL Console)...
>> url: join http:// "www.asdfasdf.com:123/path/path/file.htm"
== http://www.asdfasdf.com:123/path/path/file.htm
>> url-obj: decode-url url
decode-url has created an object there which can be looked at with probe...
>> probe url-obj
make object! [ user: none pass: none host: "www.asdfasdf.com" port-id: 123 path: "path/path/" target: "file.htm" ] as well as being accessed and changed in the normal way...
>> url-obj/host
== "www.asdfasdf.com"
>> url-obj/port-id
== 123
>> join url-obj/path url-obj/target
== "path/path/file.htm"
>> url-obj/port-id: 80
== 80
>> probe url-obj
make object! [ user: none pass: none host: "www.asdfasdf.com" port-id: 80 path: "path/path/" target: "file.htm" ] HTH. -- Carl Read

 [4/6] from: tomc:darkwing:uoregon at: 13-Nov-2002 22:21


with a well formed url 'decode-url does even better ...
>> u: "http://www.asdfasdf.com:123/path/path/file.htm"
== "http://www.asdfasdf.com:123/path/path/file.htm"
>> w: decode-url u >> probe w
make object! [ user: none pass: none host: "www.asdfasdf.com" port-id: 123 path: "path/path/" target: "file.htm" ]
>>
On Thu, 14 Nov 2002, Blackeye Silverseeker wrote:

 [5/6] from: gchiu:compkarori at: 14-Nov-2002 20:30


On Thu, 14 Nov 2002 22:19:07 -0400 Blackeye Silverseeker <[blackeye--subdimension--com]> wrote:
>Hello, i am new to rebol and i have a parsing problem. If >somebody could help me, i'd be grateful.
<<quoted lines omitted: 3>>
>"/" ] | [ to "/"]] copy path to end ] >> url: "www.asdfasdf.com:123/path/path/file.htm"
== "www.asdfasdf.com:123/path/path/file.htm"
>> parse/all url [ copy host to ":" skip copy port to "/" skip copy path to end ]
== true
>> host
== "www.asdfasdf.com"
>> port
== "123"
>> path
== "path/path/file.htm" -- Graham Chiu

 [6/6] from: blackeye::svk::subdimension::com at: 14-Nov-2002 15:25

Tank you all, i will use decode-url


> Hello, i am new to rebol and i have a parsing problem. If > somebody could help me, i'd be grateful. Here is the code
<<quoted lines omitted: 12>>
> [rebol-request--rebol--com] with "unsubscribe" in the > subject, without the quotes.
_____________________________________________________________________ // free anonymous email || forums \\ subZINE || anonymous browsing subDIMENSION -- http://www.subdimension.com

Notes
  • Quoted lines have been omitted from some messages.
    View the message alone to see the lines that have been omitted