Let's assume we have following line in our HA proxy file:
reqrep ^([^\ :]*)\ /api/v1/api-name/(.*) \1\ /staging/path-name/\2
Here is our sample domain:
https://example.com/api/v1/api-name/
The goal here is to rewrite /api/v1/api-name/
to /staging/path-name/
leaving anything else unchanged.
Breaking the Regex and understanding in parts:
There are basically 3 parts in the regex: