Returns the first match of a semver version number in the path.
@param $path
@return mixed
14635
private static function getVersionFrom($path)
    {
        $matches = [];
        preg_match(self::$semverRegex, $path, $matches);

        return array_shift($matches);
    }
127276
public static function getHandlerByPath($path)
    {
        $result = null;
        $path   = self::prepareRoute('/'.trim($path, " /"));

        foreach (static::$routes as $key => $handler) {
            $matches = [];
            if (preg_match('#'.$key.'$#i', $path, $matches)) {
                foreach ($matches as $key => $val) {
                    if (!is_numeric($key)) {
                        $_GET[$key] = $val;
                    }
                }
                $result = $handler[1];
                break;
            }
        }
        return $result;
    }
353315
protected static function getRelativePath($path)
	{
		preg_match('/([[:alpha:]]*):\/\/(.*)/', $path, $name);

		if (isset($name[2]) && $name[2])
		{
			return $name[2];
		}

		return $path;
	}
1144658
public function find($path)
    {
        $language = $this->getLanguage();
        $fallback = $this->getLanguageFallback();
        $locator  = $this->getObject('translator.locator.factory')->createLocator($path);

        $results = [];

        // Try to load the fallback translations first
        if ($fallback && $fallback != $language)
        {
            if ($result = $locator->locate($path .'/'.$fallback.'/'.$fallback.'.*')) {
                $results[] = $result;
            }
        }

        // Find translations based on the language
        if ($result = $locator->locate($path .'/'.$language.'/'.$language.'.*')) {
            $results[] = $result;
        }

        return $results;
    }
491720
protected function findFileAt($path)
    {
        try {
            $files = $this->fromDirectory('')
                ->withPrefix($path)
                ->withDelimiter('')
                ->limit(1)
                ->get();
        } catch (ApiRequestFailedException $e) {
            return;
        }

        return $files->get(0);
    }
42207
protected function getClassFromFile($path)
    {
        $count = count($tokens = token_get_all(file_get_contents($path)));

        for ($i = 2; $i < $count; ++$i) {
            if ($tokens[$i - 2][0] == T_CLASS && $tokens[$i - 1][0] == T_WHITESPACE && $tokens[$i][0] == T_STRING) {
                return $tokens[$i][1];
            }
        }
    }
1009382
private static function getRevisionFrom($path)
    {
        $matches = [];
        preg_match(self::$revisionRegex, $path, $matches);

        $match = array_shift($matches);
        return substr($match, 0, 7);
    }
1043881
protected function findText($path)
    {
        foreach ($this->localeSequence() as $locale) {
            $arrayKey = "$locale.$path";
            if (isset($this->data[$arrayKey])) {
                return $this->data[$arrayKey];
            }
        }
        return $path;
    }
1154163
private function normalizeForFnmatch(string $path): string
    {
        // ends with *
        if (Strings::match($path, '#^[^*](.*?)\*$#')) {
            return '*' . $path;
        }

        // starts with *
        if (Strings::match($path, '#^\*(.*?)[^*]$#')) {
            return $path . '*';
        }

        return $path;
    }
596705
protected function _normpath($path) {
		$tmp =  preg_replace("/^\//", "", $path);
		$tmp =  preg_replace("/\/\//", "/", $tmp);
		$tmp =  preg_replace("/\/$/", "", $tmp);
		return $tmp;
	}
1032454
protected function _getRalativePath($path)
    {
        if ($path) {
            $rootPath = str_replace(array('/', '\\'), '/', self::$_config['root']);

            $path = str_replace(array('/', '\\'), '/', $path);
            $path = str_replace($rootPath, '/', $path);
            $path = str_replace('//', '/', $path);
            $path = trim($path, '/');
        }
        return $path;
    }
584804
public function searchAction($path)
    {
        try {
            $this->setPath($path);
        } catch (NotFoundException $e) {
            throw $e;
        }

        $search = $this->wdb->getRequest()->getArgument('s');
        if (empty($search)) {
            return $this->indexAction($path);
        }

        $_s = Helper::makeSearch($search, $this->getPath());

        $title          = _T('Search for "%search_str%"', array('search_str'=>$search));
        $breadcrumbs    = TemplateHelper::getBreadcrumbs($this->getPath());
        $breadcrumbs[]  = $title;
        $dbfile         = new WDBFile($this->getpath());
        $page           = $dbfile->getWDBStack();
        $page['type']   = 'search';
        $tpl_params     = array(
            'page'          => $page,
            'breadcrumbs'   => $breadcrumbs,
            'title'         => $title,
        );

        $search_content = $this->wdb->display($_s, 'search', array(
            'search_str'    => $search,
            'path'          => TemplateHelper::buildPageTitle($this->getPath()),
        ));
        return array('default', $search_content, $tpl_params);
    }
747404
public function matchingFirstSegments(Path $anotherPath) {
		$segments = $anotherPath->segments();
		$count = 0;
		foreach ($this->segments as $i => $segment) {
			if ($segment != $segments[$i]) {
				break;
			}
			$count++;
		}
		
		return $count;
	}
78298
private function findPackageVersion($path, $fallback = null)
    {
        if (file_exists("$path/.git")) {
            $cwd = getcwd();
            chdir($path);

            $output = [];
            $status = null;
            exec('git rev-parse HEAD 2>&1', $output, $status);

            chdir($cwd);

            if ($status == 0) {
                return isset($fallback) ? "$fallback ($output[0])" : $output[0];
            }
        }

        return $fallback;
    }
879734
public function findByPath(string $path)
    {
        return $this->first(function(ExtensionContract $extension) use($path) {
                    return $extension->getPath() === $path;
                });
    }
419550
public static function getFileNameFromPath($path)
    {
        $matches = [];
        $pattern = sprintf('|([^\%s.]+\.[A-Za-z0-9.]+)$|', DIRECTORY_SEPARATOR);

        if ((bool)preg_match($pattern, $path, $matches)) {
            return $matches[1];
        }

        return '';
    }
971238
public function path($path)
    {
        $path  = strtolower(trim($path));
        $first = substr($path, 0, 1);
        
        if ($first == '@' && isset($this->aliases[$path])) {
            $path = $this->aliases[$path];
            
        } elseif ($first == '/') {
            $path = preg_replace('/\\//', $this->root() . '/', $path, 1);
            
        }
        if ($path = realpath($path)) {
            $path = static::clean($path);
        }
        
        return $path;
    }