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

Even more? parse

 [1/2] from: Rebolinth::nodep::dds::nl at: 29-Jul-2003 17:31


That was a wrong lefthanded hit... Still not working.. I though I had it because of the spaces missing from the initial string to search from but that was not the issue.. the result I would like -> "this is a long string" "long" is [ "this" "is" "a" "" string" ] Smash me, to let me understand it for now... Norman.

 [2/2] from: tomc:darkwing:uoregon at: 29-Jul-2003 17:02


parse has different modes depending on its arguments when both arguments are string! the effect is to return a block! with the first string split by the chars of the second string. the typical use ie to turn a string into a block of strings
>> parse string none
== ["this" "is" "a" "long" "string"]
>> parse string "s"
==["thi" "i" "a" "long" "" "tring"] broken up by whitespace and the char! s the /all refinement makes whitespace significant
>> block: parse/all s "s"
== ["thi" " i" " a long " "tring"]
>> mask: unique "thisisalongstring"
== "thisalongr" delimiters are not included in the output
>> parse string mask
== ["" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" ""] perhaps the main way parse is used is with a string and a block of rules in this mode parse returns true or false depending on whether the rules were sufficent to get you to the end of the string.
>> parse s [to "long" "long" to end]
== true
>> cs: charset mask
== make bitset! #{ 00000000000000000000000082D31C0000000000000000000000000000000000 }
>> parse string [some cs]
== true within the rules block you use parens to do stuff in rebol instead of in parse ... words heve differnt meanings within the .. dialect of parse
>> parse s [to "long" (print "hello") "long" to end]
hello == true result: copy "" parse string [ copy token to "long" (append result token) "long" copy token to end (append result token) ] == true
>> result
== "this is a string" out of time... hope that helps On Tue, 29 Jul 2003, Rebolinth wrote: