You could do the following: ^0*1*2*3*4*5*6*7*8*9*$
to detect crescents, ^9*8*7*6*5*4*3*2*1*0*$
for decreasing and ^0*|1*|2*|3*|4*|5*|6*|7*|8*|9*$
for repeated, example:
import java.util.regex.Pattern;
class Main {
public static void main(String args[]) {
// match crescente
System.out.println(Pattern.matches("^0*1*2*3*4*5*6*7*8*9*$", "1368"));
System.out.println(Pattern.matches("^0*1*2*3*4*5*6*7*8*9*$", "9321"));
// match decrescente
System.out.println(Pattern.matches("^9*8*7*6*5*4*3*2*1*0*$", "1368"));
System.out.println(Pattern.matches("^9*8*7*6*5*4*3*2*1*0*$", "9321"));
// match repetidos
System.out.println(Pattern.matches("^0*|1*|2*|3*|4*|5*|6*|7*|8*|9*$", "1111111111111"));
System.out.println(Pattern.matches("^0*|1*|2*|3*|4*|5*|6*|7*|8*|9*$", "1111111111112"));
}
}
that will bring you back:
true
false
false
true
true
false
Honestly I didn’t understand any of your question. Edit and provide better explanation, otherwise it becomes complicated to help.
– user28595
That fellow, just make it a little clearer, I couldn’t quite understand it either
– DiChrist