Problem with case-insensitive (?i) regex

Per Buer perbu at varnish-software.com
Sat Dec 4 21:43:24 CET 2010


Something like this:

I'm not really familiar with flags to the pcre engine so I need some
help with this. Is this correct?

--- doc/sphinx/reference/vcl.rst	(revision 5639)
+++ doc/sphinx/reference/vcl.rst	(working copy)
@@ -288,6 +288,22 @@
     return (pipe);
   }

+Regular Expressions
+-------------------
+
+In Varnish 2.1.0 Varnish switched to using PCRE - Perl-compatible
+regular expressions. For a complete description of PCRE please see the
+PCRE(3) man page.
+
+To send flags to the PCRE engine, such as to turn on *case
+insensitivity* add the flag within parens following a question mark,
+like this:::
+
+  if (req.http.host ~ "(?i)example.com$") {
+          ...
+  }
+
+


On Sat, Dec 4, 2010 at 8:24 PM, Krzysztof Dajka <alteriks at gmail.com> wrote:
> Thanks a lot.
> It would be nice if  information about usage of case-insensitive regex
> could be put into VCL(7)
>
> On Sat, Dec 4, 2010 at 4:29 PM, Camiel Dobbelaar <cd at sentia.nl> wrote:
>>
>> On 4-12-2010 16:35, Krzysztof Dajka wrote:
>>> I'm trying to make case-insensitive regex to catch mobile browsers and
>>> redirect them to lightweight version of web page.
>>> I found this doc:
>>> http://www.varnish-cache.org/docs/2.1/faq/general.html?highlight=insensitive
>>>
>>> But using "?i" before regular expression makes VCL compiler complain:
>>
>> I fell into the same trap, because the example in the FAQ is wrong.  The
>> surrounding FAQ text has it correct.  (shame on me for not reporting it)
>>
>> The brackets are mandatory, so you have to put "(?i)" at the start.
>>
>> --
>> Cam
>>
>> _______________________________________________
>> varnish-misc mailing list
>> varnish-misc at varnish-cache.org
>> http://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc
>>
>
> _______________________________________________
> varnish-misc mailing list
> varnish-misc at varnish-cache.org
> http://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc



-- 
Per Buer, Varnish Software
Phone: +47 21 98 92 61 / Mobile: +47 958 39 117 / Skype: per.buer
Varnish makes websites fly!




More information about the varnish-misc mailing list