fork(1) download
  1. import java.util.*;
  2. import java.lang.*;
  3. import java.io.*;
  4. import java.util.regex.Matcher;
  5. import java.util.regex.Pattern;
  6.  
  7.  
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. String regex = "(?<=\\) \\d\\d[\\d\\h-]{0,100})\\d(?=[\\h\\d-]*\\d\\d$)";
  13. String string = "+(123) 123-12345\n"
  14. + "+(123) 123 12 12345";
  15.  
  16. Pattern pattern = Pattern.compile(regex, Pattern.MULTILINE);
  17. Matcher matcher = pattern.matcher(string);
  18. String result = matcher.replaceAll("*");
  19.  
  20. System.out.println(result);
  21. }
  22. }
Success #stdin #stdout 0.09s 47996KB
stdin
Standard input is empty
stdout
+(123) 12*-***45
+(123) 12* ** ***45