Get route name from path with wildcard
$pattern = '/user/*/edit';
$route_provider = \Drupal::service('router.route_provider');
$found_routes = $route_provider-&gt;getRoutesByPattern($pattern);
$route_names = [];
foreach ($found_routes as $route_name =&gt; $route_object) {
  $route_names[] = $route_name;
}