fork download
  1. import java.util.*;
  2. import java.lang.*;
  3. import java.io.*;
  4. import java.util.regex.*;
  5. class Ideone
  6. {
  7. public static void main (String[] args) throws java.lang.Exception
  8. {
  9. String s = "7108898787654351"; // **0**********351
  10. System.out.println(s.replaceAll("(?<=.{3}|^.{0,1}).(?=.*...)", "*"));
  11. System.out.println(s.replaceAll("(?<=.{3}|^|^.).(?=.*...)", "*"));
  12. }
  13. }
Success #stdin #stdout 0.07s 33776KB
stdin
Standard input is empty
stdout
**0**********351
**0**********351