My idea is something like this but I dont know the correct code
if (mystring.matches(\"[0-9.]+\")){ //do something here }else{ //do something here } <
if (mystring.matches(\"[0-9.]+\")){ //do something here }else{ //do something here }
You could use indexOf() and lastIndexOf() :
indexOf()
lastIndexOf()
int first = str.indexOf("."); if ( (first >= 0) && (first - str.lastIndexOf(".")) == 0) { // only one decimal point } else { // no decimal point or more than one decimal point }