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

[REBOL] Re: Parse - Bug?

From: pwawood::mango::net::my at: 31-May-2005 19:07

Gabriele Many thanks for the explanation. It makes a great deal of sense in that context as it preserves the positions of "arguments/data":
>> a: parse "1;2;3;4;;;;;9;10" none
== ["1" "2" "3" "4" "" "" "" "" "9" "10"]
>> a/1
== "1"
>> a/9
== "9"
>> a/5
== "" I was parsing Rebol code, the empty block in the result was a nuisance. I solved my problem by not being so lazy and specifically "parsing" using space, tab and newline rather than none. I did check the user guide but didn't see any reference to the specific position preservation behaviour only : The parse function splits the input argument, string, into a block of multiple strings, breaking each string wherever it encounters a delimiter, such as a space, tab, newline, comma, or semicolon. The none argument indicates that no other delimiters other than these. User Guide 15.2 (Perhaps I was looking in the wrong place.) I also note that this behaviour seems restricted to commas and semi-colons:
>> parse "a^-^-^-" none
== ["a"]
>> parse "b^/^/^/^/" none
== ["b"]
>> parse "c,,,," none
== ["c" "" "" ""]
>> parse "d ;;;;" none
== ["d" "" "" "" ""] Regards Peter