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

[REBOL] Re: Rebol parsing 101

From: maarten:vrijheid at: 2-Oct-2003 8:01

OK, I'll give you a simple solution for a subset of your problem, from there you can probably expand easily. Ff: parse fcontents " " Foreach [date s1 s2 money status] ff [ ;first we'll have to convert the date month: copy/part date 2 day: copy/part at date 4 2 year: copy/part at date 7 2 new-date: to-date rejoin [ day "-" month "-" year ] ; Now we can construct a block probe reduce [ new-date rejoin [s1 " " s2] to-money money status ] ] However.... this assumes that the optional string (pending) is always there. Using a bnf rule with parse/all will get you further. This will take some experimenting based on the exact format. Another strategy could be to first replace all dates with valid date formats (for REBOL that is, swapping day and month), then converting your date to a block and then parse based on REBOL types, which makes matching much easier. You may want to take a look at the parse section of the user guide. --Maarten