What is the replacement of drupal_match_path()? What is the replacement of drupal_match_path() in Drupal 8?
The following function is removed from Drupal 8. How can I achieve same functionality in Drupal 8?

function drupal_match_path($path, $patterns) {
  $regexps = &amp;drupal_static(__FUNCTION__);

  if (!isset($regexps[$patterns])) {
    // Convert path settings to a regular expression.
    // Therefore replace newlines with a logical or, /* with asterisks and the &lt;front&gt; with the frontpage.
    $to_replace = array(
      '/(\r\n?|\n)/', // newlines
      '/\\\\\*/', // asterisks
      '/(^|\|)\\\\&lt;front\\\\&gt;($|\|)/', // &lt;front&gt;
    );
    $replacements = array(
      '|',
      '.*',
      '\1' . preg_quote(config('system.site')-&gt;get('page.front'), '/') . '\2',
    );
    $patterns_quoted = preg_quote($patterns, '/');
    $regexps[$patterns] = '/^(' . preg_replace($to_replace, $replacements, $patterns_quoted) . ')$/';
  }
  return (bool) preg_match($regexps[$patterns], $path);
}
New PathMatcher service reports that the path.matcher service was introduced to deprecate most procedural functions in the path.inc file with its methods.
In particular, the equivalent of $path_matches = drupal_match_path($path, $patterns); is the following code.

$path_matches = \Drupal::service('path.matcher')-&gt;matchPath($path, $patterns);


The same service is used to check if the currently viewed page is the front page.

$is_front = \Drupal::service('path.matcher')-&gt;isFrontPage();


As usual, injecting the dependency is preferred over calling \Drupal::service().