[racket-dev] Missing pregexp syntax in Racket
On Sat, Nov 26, 2011 at 10:35:57PM -0800, Pauan wrote:
> It was brought up that my explanation was confusing, and I agree it is.
> So I'll try again. The following should return #t:
...
> (regexp-match? "\\n" "\n")
I am confused about a number of things in your emails, so for simplicity
I'm focusing on the above expression only.
Your email subject mentions pregexp, but your pattern is a string
literal, which AFAICT will be compiled into a regular expression using
regexp not pregexp. Therefore it isn't clear whether you are suggesting
a change to regexp syntax or pregexp syntax.
Currently, #rx"\\n" matches like #rx"n" and #px"\\n" is an error:
> (regexp-match? #rx"\\n" "n")
#t
> #px"\\n"
readline-input::569: read: bad pregexp string: illegal alphabetic escape
Both of these behaviors agree with the syntax documented at
http://docs.racket-lang.org/reference/regexp.html?q=regexp-match%3F#(part._regexp-syntax)
To add to my confusion, your original email mentioned #px"\\\\n", which
currently matches a backslash followed by an 'n'.
Perhaps you are suggesting that #px"\\n" should mean the same as
#px"\n" rather than being an error? I don't see a need for this but
perhaps you have a rationale in mind?
David