[racket-dev] Missing pregexp syntax in Racket

From: Pauan (pcxunlimited at gmail.com)
Date: Sun Nov 27 00:10:05 EST 2011

Racket pregexp syntax is currently missing the following:

#px"\\\\X"                        -> a single Unicode grapheme
#px"\\\\u[a-fA-F0-9]{4}"          -> hexidecimal Unicode escapes
#px"\\\\u\\{[a-fA-F0-9]{1,4}\\}"  -> hexidecimal Unicode escapes
#px"\\\\x[a-fA-F0-9]{2}"          -> \x escapes
#px"\\\\n"                        -> newline
#px"\\\\r"                        -> linefeed
#px"\\\\t"                        -> tab
#px"\\\\a"                        -> \x07
#px"\\\\e"                        -> \x1B
#px"\\\\f"                        -> \x0C
#px"\\\\v"                        -> \x0B

In other words:

(regexp-match? "\n"  "\n")  -> #t
(regexp-match? "\\n" "\n")  -> #f

(regexp-match? "\u00E0"  "\u00E0")  -> #t
(regexp-match? "\\u00E0" "\u00E0")  -> #t

(regexp-match? "\\X"     "\u00E0")  -> #f
(regexp-match? "\\u{E0}" "\u00E0")  -> #f

---

Most of the above is just adding in pregexp escape sequences for things that
already exist in Racket.

However, the \\X and \\u{E0} syntax are new.


Posted on the dev mailing list.