mardi 29 août 2017

Java regular expression statement expansion

I have a simple Java class to validate Visa and Mastercard numbers:

public class ValidateCC
{
  public static void main(String[] args)
  {
    String ccStr = "4543600322751739";
    System.out.print(ccStr.matches("(4|5)[0-9]{15}"));
  }
}

I need to expand this regular expression by validating another type of card number that must begin with 35, 97 or 65.

How can I achieve this please?

Thanks.

Aucun commentaire:

Enregistrer un commentaire