[COFF] Requesting thoughts on extended regular expressions in grep.

Steffen Nurpmeso steffen at sdaoden.eu
Tue Mar 7 07:49:05 AEST 2023


Dan Cross wrote in
 <CAEoi9W6tZ+55MSPxPoZqfS3k9RO9MOQqB0yu=MO_vzzw0K6Lhw at mail.gmail.com>:
 |On Mon, Mar 6, 2023 at 5:02 AM Ed Bradford <egbegb2 at gmail.com> wrote:
 |>[snip]
 |> I would like to extend my program to
 |> any date format. That would require
 |> a much bigger RE. I have been led to
 ...
 |> one could match
 |>
 |>   Monday, March 6, 2023
 |>   2023-03-06
 |>   Mar 6, 2023
 |>   or
 ...
 |This reminds me of something that I wanted to bring up.

Me too.  If it becomes something regular and stable maybe turn
into a dedicated parser.  (As a lex yacc bison byacc refuser, but
these surely can too.)

 |Perhaps one _could_ define a sufficiently rich regular expression that
 |one could match a number of date formats. However, I submit that one
 |_should not_. REs may be sufficiently powerful, but in all likelihood
 ...

Kurt Shoens implemented some date template parser for BSD Mail in
about 1980 that was successively changed many years later by
Edward Wang in 1988 ([1] commit
[309eb459e35f77985851ce143ad2f9da5f0d90da], 1988-07-08 18:41:33
-0800).  There is strftime(3), but it came later than both to
CSRG, and the Wang thing (in usr.bin/mail/head.c) is a dedicated
thing.

(Ie
  /* Template characters for cmatch_data.tdata:
   * 'A'   An upper case char
   * 'a'   A lower case char
   * ' '   A space
   * '0'   A digit
   * 'O'   An optional digit or space; MUST be followed by '0space'!
   * ':'   A colon
   * '+'  Either a plus or a minus sign */

and then according strings like "Aaa Aaa O0 00:00:00 0000".)

  [1] https://github.com/robohack/ucb-csrg-bsd.git

--steffen
|
|Der Kragenbaer,                The moon bear,
|der holt sich munter           he cheerfully and one by one
|einen nach dem anderen runter  wa.ks himself off
|(By Robert Gernhardt)


More information about the COFF mailing list