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 fileText = "http://e...content-available-to-author-only...e.com//foo/bar http://e...content-available-to-author-only...e.com//foo/bar 1: 2/";
  10. String pattern = "(\\bhttps?://)|[:/]";
  11. Pattern r = Pattern.compile(pattern);
  12. Matcher m = r.matcher(fileText);
  13.  
  14. while (m.find()) {
  15. if (m.group(1) != null)
  16. m.appendReplacement(sb, m.group(1));
  17. else
  18. m.appendReplacement(sb, " ");
  19. }
  20. m.appendTail(sb);
  21. System.out.println(sb);
  22. }
  23. }
Success #stdin #stdout 0.04s 711168KB
stdin
Standard input is empty
stdout
http://e...content-available-to-author-only...e.com  foo bar http://e...content-available-to-author-only...e.com  foo bar  1  2