Can rewrite support dynamic URL?

My requirement is that: how can I rewrite a URL with path parameters? For example:
The original URL is “/services/v4/books/111/detail”, it should be rewrite to “/detail/111”.
That means the path parameter should be transfer to the new one.
The target URL format is “detail/{id}”, but if I config as below, it doesn’t work.
Here is my configuration:
http:

  • match:
    • uri:
      regex: /services/v4/books/\d+/detail
      rewrite:
      uri: /detail