function system_extract_version($version_string) { $core_version = substr(VERSION, 0, strpos(VERSION, '.')); $pattern = '/DRUPAL-'. $core_version .'(?:--(?P\d+)(?:-(?P\d+))?)?/'; if (!$version_string) { $version = t('undefined'); } elseif (empty($version_string)) { $version = t('latest dev'); } elseif (preg_match($pattern, $version_string, $matches)) { if (!isset($matches['major'])) { $version = "$core_version.x-dev"; } elseif (!isset($matches['minor'])) { $version = "$core_version.x-{$matches['major']}-dev"; } else { $version = "$core_version.x-{$matches['major']}-{$matches['minor']}"; } } return $version; }