Match a URL against a route pattern with :params. Input: line 1 — pattern (e.g. /users/:id/posts/:postId); line 2 — URL path. Print the params object as JSON if it matches (same segment count, literals equal), else no match.
Input: two lines.
Output: params JSON or no match.
Your program reads from stdin and prints to stdout.
Example 1
Input: /users/:id /users/42
Output: {"id":"42"}
Hints
Match a URL against a route pattern with :params. Input: line 1 — pattern (e.g. /users/:id/posts/:postId); line 2 — URL path. Print the params object as JSON if it matches (same segment count, literals equal), else no match.
Input: two lines.
Output: params JSON or no match.
Your program reads from stdin and prints to stdout.
Example 1
Input: /users/:id /users/42
Output: {"id":"42"}
Hints