I have an expression that I am trying to match the format for using regex. Some of it works, but not all. This works:
String i="3-3";
if(i.matches("[\\d]"+"-"+"[\\d]"))
System.out.println("correct!");
This does not:
String i="3-3,2-3";
if(i.matches("[\\d]"+"-"+"[\\d]{1+}"))
System.out.println("correct!");
{1+} tries to guarantee at least one instance (ex: 3-4), but it does not work.
My eventual goal is to write a regex expression that can recognize any combination of numbers like this (the numbers could be any positive integer (assumed). The second number will always be larger than the first. The pairs could include letters and should be in ascending order):
"3-4,5-7C,9-22,22A-27", etc
1A-2Blegal in your book?