As Chris mentioned, a custom reader can do this.
An example of a reader that Racket already supplies, that you could use, is at-exp
:
#lang at-exp racket
@~a{C:\Windows\win.ini}
;; "C:\\Windows\\win.ini"
@~a{This is a string
with newlines.}
;; "This is a\nstring with newlines."
I like to use ~a
with this because it converts anything to a string, and it's only two characters to type.
However for your regexp example, you can't use ~a
or #rx
. Instead you should use regexp
:
@regexp{(.*)\1}
;; #rx"(.*)\\1"
In all of these examples, @function{string}
is read as (function "string")
-- basically. There are some nuances you can read about in the documentation for at-exp
and Scribble.