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

got my brainfart parse answer

 [1/3] from: timewarp:sirius at: 6-Jun-2001 14:26


remember bo? this is what he showed me:
>> rule: [thru "x" mark: to "y" y: :mark to "z" z: (either (index? y) <
index? z [a: copy/part mark y][a: copy/part mark z])]
>> parse "x .... ab z cd y" rule
== false
>> a
== " .... ab "
>> parse "x .... ab cd y z" rule
== false
>> a
== " .... ab cd " and, this is what i wanted. unfortunately, it's not what i wanted to see... now i have to redesign my data structures as well as a significant portion of the script... *sigh* cheerfulness, -----EAT -- Erin A. Thomas --- == --- (707) 463-8578 ---- www.mochinet.com ----

 [2/3] from: jeff:rebol at: 6-Jun-2001 23:06


Hello, EAT: Sure -- I remember bo.
> remember bo? > > this is what he showed me: > > rule: [thru "x" mark: to "y" y: :mark to "z" z: (either > (index? y) < index? z [a: copy/part mark y][a: copy/part > mark z]) >]
In which case you are really just using PARSE as if it were a fancy FORALL (but less efficiently since the above method goes over the string multiple times). Your code might be cleaner, more understandable, and thereby easier to maintain if you went ahead and used FORALL instead: xYorZ: func [src /local x][ x: find/tail src "x" copy/part x forall x [if find "zy" x/1 [break/return x]] ]
> ... now i have to redesign my data structures as well as a > significant portion of the script... *sigh*
Sounds very tightly coupled. Best of luck-- -jeff

 [3/3] from: timewarp::sirius::com at: 7-Jun-2001 3:35


Jeff Kreis wrote:
> xYorZ: func [src /local x][ > x: find/tail src "x" > copy/part x forall x [if find "zy" x/1 [break/return x]] > ]
*slaps hand on forhead* yep, this certainly makes more sense. thanks jeff. cheerfulness, -----EAT -- Erin A. Thomas --- == --- (707) 463-8578 ---- www.mochinet.com ----