On 07/20/2018 12:03 AM, Aleksandar Lazic wrote:
Hi.
On 18/07/2018 13:10, Haim Ari wrote:
Hello,
Trying to set backend by regexp
This regexp works outside of haproxy
String:
/1.0/manage/bu/ca?token=68bf68bf68bf68bf68bf&segId=1212121212&partner=123456789
Regexp:
^\/1\.0\/manage\/bu\/ca\?token=.*.segId=.*=123456789
What is the right syntax for this in haproxy ?
I would use
https://regex101.com/r/TjH7Ul/1/
^\/1\.0\/manage\/bu\/ca\?token=(.*).segId=(.*).partner=123456789
AFAIK, even if this is correct, you do not have to escape the '/'
characters to match them. You had to do that in your GUI because you
selected a regex form with '/' as delimiter character (/.../gm).
haproxy uses POSIX regexes with ^.[$()|*+?{\ as list of characters which
must be escaped if you want them to be interpreted as literal characters
(see regex(7)).
There is an explanation in your GUI which indicates exactly that:
"\/ matches the character / literally (case sensitive)"
So, the regex above may be shortened as follows:
^/1\.0/manage/bu/ca\?token=(.*).segId=(.*).partner=123456789
which is a bit more readable.
Fred.