[REBOL] [REBOL]string to series function Re:(3)
Hi tim, just-one: pick parse/all "one#two%three four" "#% " 1 or just-one: first parse/all "one#two%three four" "#% " or, if want to continue collecting the complete block in my-series: just-one: pick my-series: parse/all "one#two%three four" "#% " 1 and just-one: first my-series: parse/all "one#two%three four" "#% " Note that pick is safer, it will return none if parse returns none or if parse returns an empty block, whereas first will fail with an error exception in both cases. At 09:07 PM 4/10/00 -0800, you wrote: Sterling showed me how the following code gives me a block parse "one#two%three four" "#%" == ["one" "two" "three" "four"] that's great! Now if I write: my-series: parse "one#two%three four" "#%" just-one: my-series/1 just-one is returned as "one" now how do I get "one" into just-one with 1 line of code instead of two? thanks again tim ;- Elan [: - )]
[REBOL] [REBOL]string to series function Re:(3)
Fair enough. I have little time to give a complete course on parse so I went for the shortest version. I expected to see a few other responses to this thread as well and sure enough the old-time REBOL-masters of the outside world give a more full answer than us insiders have time for. Take it easy guys, Sterling Hi Sterling, one little detail: your approach works well enough with this particular example because space is one of the desired delimiters. Conceivably Tim may want a more universal solution that enables him to determine whether or not he wants to include spaces in his parse rule. In that case IMHO it would be more appropriate to use parse's all refinement and - for the sake of this particular example - include space explicitly as a delimiter in the rule: With space: parse/all "one#two%three four" "%# " == ["one" "two" "three" "four"] Without space parse/all "one#two%three four" "%#" == ["one" "two" "three four"] Note that the second version returns "three four" as one string because space is not included in the rule.