Something like
```
Pattern versionPattern = (family == OsFamily.WINDOWS) ? WINDOWS_VERSION_PATTERN : UNIX_VERSION_PATTERN;
Matcher matcher = versionPattern.matcher(name);
if (matcher.matches()) {
   version = matcher.group(1);
}
...
```
?