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

[REBOL] Re: parse again

From: al:bri:xtra at: 28-Dec-2000 13:48

> I have a diary I want to parse like this: > > test: { 9.00 am Get up 9.30 am have breakfast 10.00 am read email }
An alternative is to use block! parse:
>> test: [ 9:00 "Get up" 9:30 "Have breakfast" 10:00 "read email"]
== [9:00 "Get up" 9:30 "Have breakfast" 10:00 "read email"]
>> parse test [any [time! string!]]
== true Of course, that requires that the data be in Rebol compatible format.
> I want to copy all the entries for each time period, including the time,
to a list.
> I tried: > > digit: charset "0123456789" > > parse test [ to 1 2 digit (print 1) ]
'to is a little limited. It only seems to work with string! or end. What you need is something like: Test: { 9.00 am Get up 9.30 am have breakfast 10.00 am read email} Diary: make block! 0 Digit: charset "0123456789" LoAlpha: charset "abcdefghijklmnopqrstuvwxyz" HiAlpha: charset "ABCDEFGHIJKLMNOPQRSTUVWXYZ" Alpha: union LoAlpha HiAlpha Time: [1 2 Digit "." 2 Digit ["am" | "pm"]] parse test [ any [ copy TimeEntry Time copy Entry some [Alpha | " "] ( repend Diary [TimeEntry trim Entry] ) | skip ] end ]
>> Diary
== ["9.00 am" "Get up" "9.30 am" "have breakfast" "10.00 am" "read email"] I hope that helps! Andrew Martin ICQ: 26227169 http://members.nbci.com/AndrewMartin/