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

[REBOL] Re: Extracting a date..

From: gjones05:mail:orion at: 12-May-2001 10:14

From: "P-O Yliniemi"
> Hi, > > I have tried to extract a date in a format (currently) not supported
by REBOL,
> without any great success.. > > The part of the file I want to read from looks like: > > fdata: { > ----------------------------------------------------------------------
------
> Some other text here > May 11 2001 > Some other text here > ----------------------------------------------------------------------
------
> } > > which should be very easy to parse.. (from some other alike answer I
found in
> the list): > > Setting up a rule for the date format: > > digit: charset [#"0" - #"9"] > mon-abbrev: ["jan" | "feb" | "mar" | "apr" | "may" | "jun" | > "jul" | "aug" | "sep" | "oct" | "nov" | "dec"] > date-rule: [mon-abbrev some #" " 1 2 digit some #" " 4 digit] > > then.. the problem begins.. > > >> date: copy "" parse fdata [to date-rule copy date to "^/" to end]
print date
> ** Script Error: Invalid argument: mon-abbrev some 1 2 digit some
4 digit
> ** Near: parse fdata [to date-rule copy date to "^/" to end] > > >> date: copy "" parse fdata [to "may" copy date to "^/" to end] print
date
> May 11 2001 > > >> date: copy "" parse fdata [[to "may" | "jun"] copy date to "^/" to
end] print date
> May 11 2001 > > >> date: copy "" parse fdata [[to "apr" | "may" | "jun"] copy date to
^/ to end] print date
> (nothing) > > ... > > What should I change to make this work ? The first try which returned
the script
> error seems to be the most logical one... > > /PeO
Hi, PeO, Looks simple; surprisingly tough. Here is what I came up with. It allows for dates with single spaces or a comma-space combination. I had trouble working in additional component separators, and I don't understand why. But here it is: fdata: { ------------------------------------------------------------------------ ---- Some other text here May 11 2001 Some other text here ------------------------------------------------------------------------ ---- } mon-abbrev-start: [ to "jan" | to "feb" | to "mar" | to "apr" | to "may" | to "jun" | to "jul" | to "aug" | to "sep" | to "oct" | to "nov" | to "dec" ] skip-spacers: [thru " " | thru ", "] digit: charset [#"0" - #"9"] s: e: none parse/all fdata [mon-abbrev-start s: skip-spacers 1 2 digit skip-spacers 2 4 digit e: to end] copy/part s e --Scott Jones