fork(1) download
  1. import java.util.*;
  2. import java.util.regex.*;
  3. import java.lang.*;
  4. import java.io.*;
  5.  
  6. class Ideone
  7. {
  8. public static void main (String[] args) throws java.lang.Exception
  9. {
  10. String text = "0001113033AA55608981";
  11. Matcher mr = Pattern.compile("^(0*\\w{4})(.*)(\\w{4})$").matcher(text);
  12. text = mr.replaceFirst(m -> m.group(1) + "*".repeat(m.group(2).length()) + m.group(3));
  13. System.out.println(text);
  14. }
  15. }
Success #stdin #stdout 0.16s 58228KB
stdin
Standard input is empty
stdout
0001113*********8981