Have searched for my solution on google and finally decided to post a question here.
My requirement is to send only A C and R characters as input and the maximum length of the string passed should not be more than 6 characters.
Following are the valid states:
A,C,R,
A,R,C,
R,A,C,
R,C,A,
C,R,A,
C,A,R,
R,C,
C,R,
A,R,
R,C,
A,
......
and so on. All possible combinations of A, C, R, are possible but the maximum lenght should not increase 6 char.
So far I am able to perform pattern validation like ([ACR],)+ but also want to perform size validation in same regex.
So for now, I'm using condition like
if(!status.matches("([ACR],)+") || status.length()>6){
SOP
}
This implementation of size I have to use across multiple methods.
Thanking in advance.