I am comparing versions numbers delivered as a string.
I need to detect whether a version is a beta release or not, I want to check if beta, build or b is included in the last part of the version and I am trying to do this with a regex.
So far it works but as soon as there is a space in the version part it doesn`t.
Maybe someone has a better idea?
My regex so far:
(\d+)(beta|build|b(\d*))?
String examples:
v1.23beta125 --> ok
v1.25.458 beta 129 --> not recognized
Sample code:
private Boolean getBeta(String str) {
boolean version = false;
Pattern p = Pattern.compile("(\\d+)(beta|build|b(\\d*))?");
Matcher m = p.matcher(str);
if (!m.find()) {
return version;
} else
version = true;
return version;
}