@Test public void clean_only_returns_the_digits() { String number = "12 34-567 "; String cleaned = CardNumberCleaner.clean(number); assertEquals("1234567", cleaned); }
public static String clean(String cardNumber) { checkNotNull("Invalid card number", cardNumber); if (!isInputAcceptable(cardNumber)) { throw new IllegalArgumentException("Invalid card number (unauthorized characters)"); } return cardNumber.replaceAll("[^\\d]", ""); }
CardNumberCleaner { public static String clean(String cardNumber) { checkNotNull("Invalid card number", cardNumber); if (!isInputAcceptable(cardNumber)) { throw new IllegalArgumentException("Invalid card number (unauthorized characters)"); } return cardNumber.replaceAll("[^\\d]", ""); } }
CardNumberCleaner { public static String clean(String cardNumber) { checkNotNull("Invalid card number", cardNumber); if (!isInputAcceptable(cardNumber)) { throw new IllegalArgumentException("Invalid card number (unauthorized characters)"); } return cardNumber.replaceAll("[^\\d]", ""); }  }
CardNumberCleaner { public static String clean(String cardNumber) { checkNotNull("Invalid card number", cardNumber); if (!isInputAcceptable(cardNumber)) { throw new IllegalArgumentException("Invalid card number (unauthorized characters)"); } return cardNumber.replaceAll("[^\\d]", ""); }  static String clean(String cardNumber); }
CardNumberCleaner { public static String clean(String cardNumber) { checkNotNull("Invalid card number", cardNumber); if (!isInputAcceptable(cardNumber)) { throw new IllegalArgumentException("Invalid card number (unauthorized characters)"); } return cardNumber.replaceAll("[^\\d]", ""); }  static String clean(String cardNumber);  }