This works with all the examples from your logcat messages:
java
Pattern pattern = Pattern.compile("\\d+\\.\\d+(\\.[\\d]+)?");
Matcher matcher = pattern.matcher(NewVersion);
if (matcher.find()) {
String version = matcher.group();
}
https://regex101.com/r/P7lICp/1
Personally, I would rethink what you are doing.