1

I want to use tftp-hpa file-remapping feature (see the man page). It uses regex, but it doesn't have much functionality. What I want is when the client send a request for foo, the server send client_IP/foo. For the moment I have this rule :

r foo \i/foo

But as you can guess, it works only for foo, whereas I want it to work whatever is the request. I've tried this :

r /.*/ \i//.*/

But it doesn't work. As the documentation and the examples aren't much, I don't know what to try, so maybe you can have some suggestions. (So yeah, I know it's not really a programing question, but as programmers you know regex and maybe you'll have the good answer)

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
Shan-x
  • 1,146
  • 6
  • 19
  • 44

2 Answers2

1

Looks like you need to use a replacement pattern: As stated in the doc, \0 stands for the "entire string matched by the regex". So try:

r .* \i/\0
Eric Leibenguth
  • 4,167
  • 3
  • 24
  • 51
  • Nop. But `r foo \i/\0` works (only for `foo`, of course). So it's the `/.*/` which doesn't work. – Shan-x May 21 '15 at 08:14
0

you need to include the matched string into the replacement. parantheses mark a positional match, starting with 1:

r /(.*)/ \i\/\1/

should do the trick (unverified)

gerhard d.
  • 136
  • 4
  • Nop, doesn't work. Note that TFTP file-remapping are so simple, I'm not even sure what I ask is possible. – Shan-x May 21 '15 at 07:43
  • Looks like parenthesis need to be escaped... From the doc: `The strings matched by each of the first nine parenthesized subexpressions, \( ... \), of the regex pattern.` – Eric Leibenguth May 21 '15 at 07:55