> On Feb 2, 2018, at 10:23 AM, 'John Clements' via Racket Users
> <firstname.lastname@example.org> wrote:
> This macro gets the names in much closer to the corresponding patterns than
> matching by index, but it doesn’t actually embed the names into the regexp.
If you like keeping the names and patterns together, you could also create an
association list of the names and subpatterns, and iterate:
(define msg "2018-02-02T11:26:34 someuser some-computername01 18.104.22.168
(for/hash ([(name pat) (in-dict '((date . "[-\\dT:]+")
(username . "\\w+")
(hostname . "[-\\w\\d]+")
(ip . "[\\d\\.]+")
(message . ".+")))])
(values name (car (regexp-match (pregexp pat)
'#hash((message . #" something broke")
(date . #"2018-02-02T11:26:34")
(username . #"someuser")
(hostname . #"some-computername01")
(ip . #"22.214.171.124"))
You received this message because you are subscribed to the Google Groups
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
For more options, visit https://groups.google.com/d/optout.