fork(13) download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6. import java.io.*;
  7. import java.util.regex.PatternSyntaxException;
  8.  
  9. /* Name of the class has to be "Main" only if the class is public. */
  10. class Ideone
  11. {
  12. public static void main (String[] args) throws java.lang.Exception
  13. {
  14. String test = "something https://google.com something";
  15. try {
  16. String newText = test.replaceAll("(https?|ftp|file)://[-a-zA-Z0-9+&@#/%?=~_|!:,.;]*[-a-zA-Z0-9+&@#/%=~_|]", "");
  17. System.out.println(newText);
  18. } catch (PatternSyntaxException ex) {
  19. // Syntax error in the regular expression
  20. // Syntax error in the replacement text (unescaped $ signs?)
  21. // Non-existent backreference used the replacement text
  22. }
  23. }
  24. }
Success #stdin #stdout 0.1s 320256KB
stdin
Standard input is empty
stdout
something  something