Split words into caracters

Reinis Rozitis r at roze.lv
Tue Apr 2 15:38:51 UTC 2013


> yeah but it works when you have multiple words.

What do you mean by multiple words?


> In my case, there is only one which is 1234567890...DEF (md5 -> 32 chars)
> m=1234567890...DEF
> m[1] = 1
> m[2] = 2
> ..
> m[32] = F

> A mere rewrite is impossible here..
> It seems indeed,

Why not?


rewrite 
"/path/(?<r1>[\w]{1})(?<r2>[\w]{1})(?<r3>[\w]{1})(?<r4>[\w]{1})(?<r5>[\w]{1})(?<r6>[\w]{1})(?<r7>[\w]{1})(?<r8>[\w]{1})(?<r9>[\w]{1})(?<r10>[\w]{1})(?<r11>[\w]{1})(?<r12>[\w]{1})(?<r13>[\w]{1})(?<r14>[\w]{1})(?<r15>[\w]{1})(?<r16>[\w]{1})(?<r17>[\w]{1})(?<r18>[\w]{1})(?<r19>[\w]{1})(?<r20>[\w]{1})(?<r21>[\w]{1})(?<r22>[\w]{1})(?<r23>[\w]{1})(?<r24>[\w]{1})(?<r25>[\w]{1})(?<r26>[\w]{1})(?<r27>[\w]{1})(?<r28>[\w]{1})(?<r29>[\w]{1})(?<r30>[\w]{1})(?<r31>[\w]{1})(?<r32>[\w]{1})" 
/realpath/$r1/$r2/$r3/$r4/$r5/$r6/$r7/$r8/$r9/$r10/$r11/$r12/$r13/$r14/$r15/$r16/$r17/$r18/$r19/$r20/$r21/$r22/$r23/$r24/$r25/$r26/$r27/$r28/$r29/$r30/$r31/$r32;

It looks somewhat ugly  because of 32 variables (aso because you need to use 
named ones (since $10/$11 ... wouldnt work)).
There are probably much better ways to do this, but as a proof of concept it 
works:



Request to http://someserver/path/aBcdfghjklqwertyuiopas1234567890 gets 
rewritten/translated to:

2013/04/02 18:25:37 [error] 2032#0: *60 open() 
"/www/realpath/a/B/c/d/f/g/h/j/k/l/q/w/e/r/t/y/u/i/o/p/a/s/1/2/3/4/5/6/7/8/9/0" 
failed (2: No such file or directory), request: "GET 
/path/aBcdfghjklqwertyuiopas1234567890

(obviously error since such file doesnt exist for me)

:)


rr 



More information about the nginx mailing list