You can split your string by space char, and then you will have an array like this [“Number”, “5”, “hurray”]. So the number you are looking for is always on position 1.
String s = "Number 5 hurray";
String[] array = s.split(" ");
String number = array[1]; // here your number
solved Find a variable in a value in a string Android Studio, Java [duplicate]