0

I have a URL which needs to be filtered from a certain logs if it has user-specific information.

URL looks something like this: /v1/info/infor1/users/ABC (/v1/info/:info/users/:userID #info and userID are parameters)

If I write a regex like /v1/info/.*/users/.*, will it filter all URLs starting with /v1/info? If yes, how do I make sure the filtering happens only based on the URL containing the userUID?

Tried /v1/info/.*/users/.* and it matches URLs like /v1/info/infor1/users/ABC and not /v1/info/details and I am not sure how it works. Does .* not compare everything from that point?

Andrew Morton
  • 24,203
  • 9
  • 60
  • 84
Neha Ahir
  • 1
  • 1
  • Using `.*` matches the whole line and then backtracks to fit in the match for `/users/` If you must be sure to have 5 forward slashes in total `^/v1/info/[^/]+/users/[^/]+$` https://regex101.com/r/wMFfQL/1 – The fourth bird Dec 08 '22 at 14:15

0 Answers0