I'm working on some code that generates PCRE patterns used to ban objects in varnish and having a problem with varnish telling me the pattern is invalid.
This is one of the patterns generated by my code
(?i)(((^| )page\-2[^ ]*($| )))
And this is what varnish is telling me
0 Debug - "REGEX: <missing )>"
13 RxRequest c BAN
13 RxURL c /
13 RxProtocol c HTTP/1.1
13 RxHeader c User-Agent: curl/7.34.0
13 RxHeader c Accept: */*
13 RxHeader c Host: www.test.local
13 RxHeader c X-Tags: (?i)(((^| )page\-2[^ ]*($| )))
I've even tried simplifying the pattern during testing to this
page-2[^ ]
page\-2[^ ]
And I get this
0 Debug - "REGEX: <missing terminating ] for character class>"
A simple pattern like this works
page-2.*
I'm running varnish-3.0.2 revision cbf1284
The relevant VCL is
if (req.request == "BAN") {
ban("obj.http.X-Tags ~ " + req.http.X-Tags);
error 200 "Banned";
}