Hi people,
i try to check the 3. Verification criteria of the task:
3) the number may contain 0-2 non-consecutive '-' characters
with
public class Test {
public static void main(String[] args) {
String s = "+3805012f3-45-67";
//s = "A";
String regex = "[-]{0,2}";
if (s.matches(regex))
System.out.println("Yes.");
else
System.out.println("No.");
}
}
It should show "Yes" but it shows "No". What am I doing wrong?
Best Regards
Vincenzo