fork 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. class Ideone
  8. {
  9. public static void main (String[] args) throws java.lang.Exception
  10. {
  11. String[] strings = {
  12. "/a.b.c.e",
  13. "a.b.c.d.e"
  14. };
  15. String regex = "a\\.b\\.c\\.(?!d\\.)(.*)";
  16.  
  17.  
  18.  
  19. for (String s : strings) {
  20. System.out.println(s.replaceFirst(regex, "a.b.c.d.$1"));
  21. }
  22. }
  23. }
Success #stdin #stdout 0.07s 53656KB
stdin
Standard input is empty
stdout
/a.b.c.d.e
a.b.c.d.e