The following example filters dates in the form DD-MMM-
YYYY, for example 11-OCT-1999. Because it only filters
this one form of date, it is quicker than the built-in
date filter which filters many different date formats.
It is also not the exact equivalent of the built-in
date filter in other respects, for example it treats
37-NOV-0999 as a date, but should be sufficient for
most purposes.
day := any(" 123") + digit;
month := "JAN" | "FEB" | "MAR" | "APR" |
"MAY" | "JUN" | "JUL" | "AUG" |
"SEP" | "OCT" | "NOV" | "DEC";
year := any(digits,4);
date := day + "-" + month + "-" + year;
global_replace( date, "dd-mmm-yyyy");
This filter defines the pattern variables "day",
"month" and "year" which are then used to define the
pattern variable "date" used in the call to global_
replace.
The "day" pattern uses the DECTPU function "any" to
match either a space or one of the characters "1", "2"
or "3", followed by a digit.
The "month" pattern uses the DECTPU pattern alternation
operator "|" to specify a list of alternative string
literals.
The "year" pattern uses the DECTPU function "any"
with the supplied pattern "digits". The "4" parameter
indicates that exactly 4 digits are to be matched.
The "date" pattern concatenates these patterns and
linking punctuation.