Upper and lower case strings in Varnish

Laurence Rowe l at lrowe.co.uk
Wed Feb 3 18:28:02 CET 2010

I don't think it's possible to write a regex that will do that in one
go. There's a dumb solution though:

    set obj.http.Location regsuball(obj.http.Location, "A", "a");
    set obj.http.Location regsuball(obj.http.Location, "B", "b");


On 3 February 2010 17:15, Richard Chiswell
<richard.chiswell at mangahigh.com> wrote:
> Hi Poul,
> Poul-Henning Kamp wrote:
>> In message <4B69AB1A.6010406 at mangahigh.com>, Richard Chiswell writes:
>>> I've got a simple question which I've been puzzling on for the last 30
>>> minutes or so - how do you change a string in Varnish to lowercase?
>> You'll have to use a bit of inline C code to do that.
> Thanks Poul - any chance of any example of how to do this with a regular
> expression: we currently have:
> set obj.http.Location = "http://" req.http.host "/"
> regsub(req.url,"^/(en_gb/|en_us/)?([A-Za-z]+)/?(.*)$","\1\2");
> but we only want the \1 lowercased -I've got to
> set obj.http.Location = "http://" req.http.host "/"
> regsub(req.url,"^/(en_gb/|en_us/)?([A-Za-z]+)/?(.*)$","C{char
> str[255];str=\1;for (i=0;str[i];i++) { str[i]=tolower(str[i]);return
> str;}C\2");
> but that doesn't seem to work. I don't suppose you can point me in the
> right direction (it's been over 10 years since I've done C [since then
> C++, C#.Net, PHP, Perl and Java: so remembering what's valid syntax is
> bad enough, and I've got no idea about the passing to/from varnish side
> of things).
> Thank you,
> Richard
> _______________________________________________
> varnish-misc mailing list
> varnish-misc at projects.linpro.no
> http://projects.linpro.no/mailman/listinfo/varnish-misc

More information about the varnish-misc mailing list