I have the following regular expression in Varnish configuration language
^/abc/([a-zA-Z0-9\-\ ]*)-([0-9]+)
Now , I want fetch the value $2
part(i.e [0-9]+
) of regular expression in Varnish.
How can I get this value?
I have the following regular expression in Varnish configuration language
^/abc/([a-zA-Z0-9\-\ ]*)-([0-9]+)
Now , I want fetch the value $2
part(i.e [0-9]+
) of regular expression in Varnish.
How can I get this value?
You may use regsub
in this case:
set req.url = regsub(req.url, "^/abc/([a-zA-Z0-9 -]*)-([0-9]+).*", "\2");
You match the whole string, capture the part you need, and replace with the appropriate backreference.