Given rules for Strings are
[Random Nr of Letters]##[Random Nr of Letters]#[Random Nr of Letters]##########
String Length has to be 35
My String e.g. looks like
TEST##TESTING#TEST#################
My problem is that I can't detect wrong formats like
TEST##TESTING#TEST##A##############
My method is:
private static boolean test(String test_line) {
String test = "[A-Z]{1,}##[A-Z]{1,}#[A-Z]{1,}#{1,}";
Pattern test_pattern = Pattern.compile(test);
Matcher matcher = test_pattern.matcher(test_line);
return matcher.find();
}
Is there an easy method with RegEx (I have to use it) like "end this String with # and don't allow other characters".
Another problem: How can I assure that my test won't allow other characters than A-Z 0-9 and #? Something like:
String test = "([^A-Z][^0-9][#])";
Pattern test_pattern = Pattern.compile(test);
Matcher matcher = test_pattern.matcher(test_line);
return matcher.find();
(with negotiating)
Thanks for the help :)