[REBOL] Re: Parse query
From: petr:krenzelok:trz:cz at: 12-Nov-2001 12:51
John R wrote:
> Andrew,
>
> Thanks but this doesn't seem to work.
>
> The REBOL parse documentation does not look very comprehensive to me for a
> feature which is obviously very powerful. I am not clear from reading it how
> your rules starting with copy are intended to work.
>
> Also can the rules enforce specific character sequences
>
> e.g. dd/mm/yyyyy because my reading of a rule like
> 2 digit "/" 2 digit "/" 4 digit is that it would allow values like
> 31 /01/ 1997 i.e. embedded white space between terms?
I don't follow the thread, so I can possibly miss the point, but as for above
example - yes, white spaces would be allowed. If you want to prevent that, use
parse in more precise way - parse/all¨:
->> help parse
USAGE:
PARSE input rules /all /case
DESCRIPTION:
Parses a series according to rules.
PARSE is a native value.
ARGUMENTS:
input -- Input series to parse (Type: series)
rules -- Rules to parse by (Type: block string none)
REFINEMENTS:
/all -- Parses all chars including spaces.
^^^^^^^
/case -- Uses case-sensitive comparison.
PS - as for single char delimiters, try following:
->> parse "11/01/1999" "/"
== ["11" "01" "1999"]
->> parse "+420-605/111222" "-/"
== ["+420" "605" "111222"]
Cheers,
-pekr-