diff --git a/Library/Homebrew/os/mac/version.rb b/Library/Homebrew/os/mac/version.rb index 3950ca1b41..e3d35aed6a 100644 --- a/Library/Homebrew/os/mac/version.rb +++ b/Library/Homebrew/os/mac/version.rb @@ -37,13 +37,17 @@ module OS def self.version_arch(value) @all_archs_regex ||= begin all_archs = Hardware::CPU::ALL_ARCHS.map(&:to_s) - /^((#{Regexp.union(all_archs)})_)?([\w.]+)(-(#{Regexp.union(all_archs)}))?$/ + / + ^((?#{Regexp.union(all_archs)})_)? + (?[\w.]+) + (-(?#{Regexp.union(all_archs)}))?$ + /x end match = @all_archs_regex.match(value) return [] unless match - version = match[3] - arch = match[2] || match[5] + version = match[:version] + arch = match[:prefix_arch] || match[:suffix_arch] [version, arch] end