fork download
  1. class Ideone
  2. {
  3. public static void main (String[] args) throws java.lang.Exception
  4. {
  5. String s = "01122222222";
  6. System.out.println(s.replaceAll("(?<=\\d{3})(\\d{2})+?", "-$1"));
  7. }
  8. }
Success #stdin #stdout 0.04s 320576KB
stdin
Standard input is empty
stdout
011-22-22-22-22