Same name and namespace in other branches
  1. 7.x includes/path.inc \drupal_match_path()

Check if a path matches any pattern in a set of patterns.

Parameters

$path: The path to match.

$patterns: String containing a set of patterns separated by \n, \r or \r\n.

Return value

1 if there is a match, 0 if there is not a match.

1 call to drupal_match_path()
block_list in modules/block/block.module
Return all blocks in the specified region for the current user.

File

includes/path.inc, line 244
Functions to handle paths in Drupal, including path aliasing.

Code

function drupal_match_path($path, $patterns) {
  static $regexps;
  if (!isset($regexps[$patterns])) {
    $regexps[$patterns] = '/^(' . preg_replace(array(
      '/(\\r\\n?|\\n)/',
      '/\\\\\\*/',
      '/(^|\\|)\\\\<front\\\\>($|\\|)/',
    ), array(
      '|',
      '.*',
      '\\1' . preg_quote(variable_get('site_frontpage', 'node'), '/') . '\\2',
    ), preg_quote($patterns, '/')) . ')$/';
  }
  return preg_match($regexps[$patterns], $path);
}