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");
...
Laurence
On 3 February 2010 17:15, Richard Chiswell
<[email protected]> wrote:
> Hi Poul,
>
> Poul-Henning Kamp wrote:
>> In message <[email protected]>, 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
> [email protected]
> http://projects.linpro.no/mailman/listinfo/varnish-misc
>
_______________________________________________
varnish-misc mailing list
[email protected]
http://projects.linpro.no/mailman/listinfo/varnish-misc