Version match

@param string title
@param string version

@return int matches
965125
protected function versionMatch($title, $version)
    {
        $title = strtolower($title);
        $version = strtolower($version);

        $version = str_replace(array('.', '-', '/'), ' ', $version);
        $versionParts = explode(' ', $version);

        $matches = array();

        foreach ($versionParts as $versionPart) {
            if (strlen($versionPart) >= 3 && stripos($title, $versionPart)) {
                $matches[] = $versionPart;
            }
        }

        $matches = count($matches);

        if ($matches > 0) {
            return $matches;
        } else {
            return false;
        }
    }
999070
protected static function matchVersion($version, $type)
    {
        $patchVersion = true;

        if (\in_array($type, array('dev', 'snapshot'), true)) {
            $type = 'dev';
            $patchVersion = false;
        } elseif ('a' === $type) {
            $type = 'alpha';
        } elseif (\in_array($type, array('b', 'pre'), true)) {
            $type = 'beta';
        } elseif (!\in_array($type, array('alpha', 'beta', 'RC'), true)) {
            $type = 'patch';
        }

        $version .= $type;

        return array($version, $patchVersion);
    }
437788
public static function compare($version)
    {
        $currentVersion = str_replace(' ', '', strtolower(self::VERSION));
        $version        = str_replace(' ', '', $version);

        return version_compare($version, $currentVersion);
    }
1055421
function compareVersion(version1, version2) {
  version1 = cleanupVersion(version1).split('.');
  version2 = cleanupVersion(version2).split('.');
  for (let i = 0; i < 3; i++) {
    let compared = compare(+version1[i], +version2[i]);
    if (compared !== 0) {
      return compared;
    }
  }
  return 0;
}
619003
public function mapOfficeVersion(string $version): string
    {
        $intVersion = (int) $version;

        if (in_array($intVersion, [2007, 2010, 2013, 2016])) {
            return (string) $intVersion;
        }

        if (16 === $intVersion) {
            return '2016';
        }

        if (15 === $intVersion) {
            return '2013';
        }

        if (14 === $intVersion) {
            return '2010';
        }

        if (12 === $intVersion) {
            return '2007';
        }

        return '0';
    }
773964
public static function isValidProtocolVersion($version)
    {
        if (!is_string($version) || empty($version)) {
            return false;
        }

        return (bool) preg_match('#^(1\.[01]|2)$#', $version);
    }
538836
def check_version(version: str):
    
    code_version = parse_version(__version__)
    given_version = parse_version(version)
    check_condition(code_version[0] == given_version[0],
                    "Given release version (%s) does not match release code version (%s)" % (version, __version__))
    check_condition(code_version[1] == given_version[1],
                    "Given major version (%s) does not match major code version (%s)" % (version, __version__))
91183
public static function compare(Version $a, Version $b)
    {
        $aValues = $a->numeric();
        $bValues = $b->numeric();

        foreach (array_keys(self::$ordinality) as $key) {
            $aVal = $aValues[$key];
            $bVal = $bValues[$key];

            if ($aVal < $bVal) {
                return -1;
            } elseif ($aVal > $bVal) {
                return 1;
            }
        }
        return 0;
    }
865757
public static function versionCompare(string $v1, string $v2, string $delimiter = '.'): int {
        $parts1 = explode($delimiter, $v1);
        $parts2 = explode($delimiter, $v2);
        $end = min($len1 = count($parts1), $len2 = count($parts2));
        for ($i = 0; $i < $end; $i++) {
            if ($parts1[$i] > $parts2[$i]) {
                return 1;
            } elseif ($parts1[$i] < $parts2[$i]) {
                return -1;
            }
        }
        return $len1 <=> $len2;
    }
1325118
private function resolveVersion($version)
    {
        if (isset($this->aliases[$version])) {
            $version = $this->aliases[$version];

            return $version;
        }

        return $version;
    }
448363
public static function laravelVersionIs($operator, $version, $laravel = null)
    {
        if (is_null($laravel)) {
            $laravel = app()->version();
        }

        $laravel = strtok($laravel, ' ');

        return version_compare($laravel, $version, $operator);
    }
1339181
function compareVersion(version, range) {
        var string = (range + '');
        var n = +(string.match(/\d+/) || NaN);
        var op = string.match(/^[<>]=?|/)[0];
        return comparator[op] ? comparator[op](version, n) : (version == n || n !== n);
    }
821412
public function containsVersionOfFile($file, $version)
    {
        $f = $this->findVersionOfFile($file, $version);
        return  $f != null;
    }
1372263
private function comparePhingVersion($version)
    {
        $current = strtolower(self::getPhingVersion());
        $current = trim(str_replace('phing', '', $current));

        // make sure that version checks are not applied to trunk
        if ('dev' === $current) {
            return 1;
        }

        if (-1 == version_compare($current, $version)) {
            throw new BuildException(
                sprintf('Incompatible Phing version (%s). Version "%s" required.', $current, $version)
            );
        }
    }
915855
public static function parse ($version)
    {
        $nums = explode(self::DELIMITER, $version);
        $numbers = array();
        foreach ($nums as $num) {
            if (preg_match('/^0*([0-9]+)/', $num, $matches)) {
                if (isset($matches[1])) {
                    $numbers[] = $matches[1];
                } else {
                    $numbers[] = 0;
                }
            } else {
                break;
            }
        }
        if (! sizeof($numbers)) {
            $numbers = array(0);
        }
        return $numbers;
    }
428604
function parseVersion(str) {
  var match = /git version ([0-9\.]+)/.exec(str);

  if (match) {
    return match[1];
  } else {
    throw new Error('Unable to parse version response', str);
  }
}
842811
private static function preReleaseEquals(PreRelease $v1, PreRelease $v2)
    {
        // If they don't match on the versionable level they can not match
        if (!self::versionableEquals($v1, $v2)) {
            return false;
        }

        // Both other parts need to match
        if ($v1->getGreek() !== $v2->getGreek()) {
            return false;
        }
        if ($v1->getReleaseNumber() !== $v2->getReleaseNumber()) {
            return false;
        }

        return true;
    }