I'm trying to create a regex that matches the inverse of a certain string type (so, strings not ending in ".js", for example).
According to the documentation, that should be the expression #rx"(?!\\.js$)"
, but it doesn't seem to work. To test it out, I have this function:
(define (match-test regex) (map (lambda (text) (regexp-match? regex text)) '("foo.js" "bar.css" "baz.html" "mumble.gif" "foobar")))
(match-test #rx"\\.js$")
returns (#t #f #f #f #f)
as expected, but (match-test #rx"(?!\\.js$)")
returns (#t #t #t #t #t)
, where I would expect (#f #t #t #t #t)
.
What am I doing wrong, and how do I actually get a regex in Racket to express the idea "match anything which does not contain [x]"?