Using capture groups in regexp replace
I need to replace url like this:
/some/prefix/url
/url/secret-suffix
I’m doing it now with 2 separate rules:
- regexp replace “^/some/prefix” with “”
- append “/secret-suffix”
What I’d do if groups were supported is:
Regex: "^/some/prefix/(.+)$"
Substitution: “/$1/secret-suffix”
Is it possible?
I read vcl-regular-expression-cheat-sheet guide but it’s talking about pure VCL, not sure how to use it in UI based config.
Seems like I could use something like if(req.url ~ "^/some/prefix(/.+)$", re.group.1 "some suffix", "")
in UI as constant Set mode (instead of Regex), but it looks overcomplicated.
Please sign in to leave a comment.
Comments
1 comment