Question: Java Code 3 numeric characters (digits), excluding 000, 666 and any number in the range of 900-999, followed by a hyphen, then 2 numeric characters

Java Code

3 numeric characters (digits), excluding 000, 666 and any number in the range of 900-999, followed by a hyphen, then 2 numeric characters (digits), followed by a hyphen and 4 numeric characters (digits).

Implement a regular expression as a Java String p like so:

String p = "*****************";

and use inside the match method:

public void match(String s) {

String p = "*****************";

System.out.println(s.matches(p)? "match " + s: "does not match " + s);

}

The test cases will invoke this method.

Example:

The following are valid identity numbers:

349-90-2839

694-12-0239

The following are invalid identity numbers:

666-29-8493

000-28-2323

912-38-2390

21-48-93043

Java Code 3 numeric characters (digits), excluding 000, 666 and any number

Test Result match ("349-90-2839"); match 349-90-2839 match ("694-12-0239"); match 694-12-0239 match ("666-29-8493" does not match 666-29-8493 match ("000-28-2323" does not match 000-28-2323 match ("912-38-2390" does not match 912-38-2390 match ("21-48-93043" does not match 21-48-93043

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!