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

[REBOL] Re: 'Parse is peculiar! - more details

From: ingo:2b1 at: 15-Dec-2000 8:19

Hi Brett, found an error in my last post, it didn't work for "<<" line1: {Lets find "Ju<<<l>ie<1234><WON:90966776>"} main-rule: [ (next-part: "") thru {"} copy name to {<} some sub-rule to end ] sub-rule: [ "<WON:" (print name) to end | (if next-part <> "" [if none? next-part [next-part: ""] append name join "<" next-part] ) skip copy next-part to "<" ]
>> parse line1 main-rule
Ju<<<l>i (if "<" are directly following each other, name-part is set to none, so I have to change to "") kind regards, Ingo Once upon a time Ingo Hohmann spoketh thus:
> Hi Brett, > > here's my take, assuming that "<WON:" is sure not to be in the name-string > (and it is the only thing you can be sure about ... > > line1: {Lets find "Ju<l>ie<97868769><1234><WON:90966776>"} > main-rule: [ (next-part: "") thru {"} copy name to {<} some sub-rule to end ] > sub-rule: [ "<WON:" (print name) to end > | (if next-part <> "" [append name join "<" next-part] ) skip copy next-part to "<" ] > > >> parse line1 main-rule > Ju<l>i<97868769> > > OK, what do I do? > > in main-rule first create an empty-string next-part (no copy needed, as the > string is not changed, the word gets assigned to new strings later on) > > Up to copy name it's the same as before, but then we go into the sub-rule. > > when entering sub-rule we are right before the "<" so we can test if it is > "<WON:" by chance, if it is, w're done, print the name, and go to the end. > > If it's not "<WON:" we first test if next-part is still "" (first pass) and > we either do nothing, or append a "<" and next-part to the name", then we > skip over the "<" (remember? that's where we entered the sub-rule!) and then > we copy the next-part of the name to the next "<" the rule ends here, but > we've told parse to check this rule multiple times (some), so we just reenter > the sub-rule ... > > I hope this helps, > > Ingo >
-- YES! That's just me, just being! http://www.2b1.de/ We ARE all ONE --- [ingo--2b1--de] --- We ARE all FREE