fork download
  1. import java.util.regex.*;
  2.  
  3. public class Main {
  4. public static void main(String[] args) {
  5. Pattern replace = Pattern.compile("^[A-Za-z][\\d]{4}$");
  6. Matcher matcher1 = replace.matcher("A1234");
  7. System.out.println("Output of A1234 = " + matcher1.replaceAll("ITS REPLACED"));
  8. Matcher matcher2 = replace.matcher("F87652");
  9. System.out.println("Output of F87652 = " + matcher2.replaceAll("ITS REPLACED"));
  10. }
  11. }
Success #stdin #stdout 0.03s 245632KB
stdin
Standard input is empty
stdout
Output of A1234 = ITS REPLACED
Output of F87652 = F87652