The pregexp.ss module provides the ability to intersperse comments in your regular expression definition using the Perl-compatible x option in the definition:
(require (lib"pregexp.ss""mzlib")
(lib"dns.ss""net"))
(definecommented-regexp
(pregexp"((?x: ; Ignore whitespace
(?x: ; Capture the inet address
(?! [\\-_] ) ; don't lookahead for underscore/dash
[\\w\\-] + ; hostname component
\\. ; dot
)+ ; repeat a few times
[A-Za-z] ; ... followed by a letter
[\\w\\-] + ; and trailing domain part
))"))
(define (make-detailed-namename)
(let* ((addr (dns-get-address"ns1.granitecanyon.com"name))
(replace (string-append"\\1 ["addr"]")))
(pregexp-replacecommented-regexpnamereplace)))
> (make-detailed-name"alpha.gnu.org")
"alpha.gnu.org [199.232.41.11]">