[REBOL] Re: Parse query
From: al:bri:xtra at: 12-Nov-2001 16:25
John wrote:
> How can I use parse to extract particular subtrings from a string e.g.
telephone no (NNN-NNN-NNNN), date (DD/MM/YYYY).
Try something like:
Digit: charset "0123456789"
str: "abcdefgh 09/11/2001 xyz"
Date: [
copy Day 2 Digit #"/" copy Month 2 Digit #"/" copy Year 2 4 Digit
]
Telephone: [
copy Number [
3 Digit #"-" 3 Digit #"-" 4 Digit
]
]
parse str [
Date | Telephone | skip
]
> Does the to keyword only support simple character string arguments?
Yes. It's been requested to feedback that more interesting arguments be
supported.
> Should I use find function instead?
'parse is nicer to use, once you use 'skip. :-)
Andrew Martin
ICQ: 26227169 http://valley.150m.com/