fork download
  1. import java.util.*;
  2. import java.lang.*;
  3. import java.util.regex.*;
  4.  
  5. class Main
  6. {
  7. public static void main (String[] args) throws java.lang.Exception
  8. {
  9. ArrayList<String> result = new ArrayList<String>();
  10. result.add("Look here http://w...content-available-to-author-only...n.com/?article=kwyjibo");
  11. result.add("No link here");
  12. result.add("cnn.com is not a link");
  13. ArrayList<String> al = new ArrayList<String>();
  14.  
  15. for(String statii: result){
  16.  
  17. String patternStr = "(https?|ftp|file)\\://[\\-a-zA-Z0-9\\+\\&\\@\\#/\\%\\?\\=\\~\\_\\|\\!\\:\\,\\.\\;]*[\\-a-zA-Z0-9\\+\\&\\@\\#\\/\\%\\=\\~\\_\\|]";
  18. Pattern pattern = Pattern.compile(patternStr);
  19. Matcher matcher = pattern.matcher(statii);
  20. if(matcher.find() == true){
  21. al.add(statii);
  22. }
  23. }
  24.  
  25. for (String match : al) {
  26. System.out.println(match);
  27. }
  28. }
  29. }
Success #stdin #stdout 0.08s 212416KB
stdin
Standard input is empty
stdout
Look here http://w...content-available-to-author-only...n.com/?article=kwyjibo