I need to validate a user input string to match specific pattern using regex in java. user input needs to match the following syntax: sv32i-a- where "sv" is always mandatory followed by 32 or 64, then "i" or "c" then "-" then "a" or "b" then "-" and then " " an empty space and then a possible repetition on the string like (sv32i-a- sv64c-b- ). Just getting confused. Thank you!
public class StringValidation {
static boolean result = true;
//Help needed here.
static String syntax = "^rv\\d{2}$"; //Code goes here but not sure about the syntax..
public static boolean isTrue(String stringToValidate) {
result = stringToValidate.matches(syntax);
return result;
}
}