[Solved] How to find a string contains XXX-XXXXXX format? java [closed]


You could use split.

String str = "XXX-XXXXXX";
String[] words = str.split("-");
if(words[0].toCharArray().length == 3 && words[1].toCharArray().length == 6 && words.length == 2)
{
    System.out.println("Correct");
}

3

solved How to find a string contains XXX-XXXXXX format? java [closed]