fork(1) download
  1. import java.util.*;
  2. import java.lang.*;
  3. import java.io.*;
  4.  
  5. class Ideone
  6. {
  7. public static void main (String[] args) throws java.lang.Exception
  8. {
  9. String input_str = "http://w...content-available-to-author-only...e.com?and=value&s=more\nhttp://10.23.46.134\nemail@me.at.site.com";
  10. String regex = "(([A-Za-z]{3,9}:(?://)?)(?:[-;:&=+$,\\w]+@)?[A-Za-z0-9.-]+|(?:www\\.|[-;:&=+$,\\w]+@)[A-Za-z0-9.-]+)((?:/[+~%/.\\w-]*)?\\??(?:[-+=&;%@.\\w]*)#?(?:[.!/\\\\\\w]*))?";
  11. String res = input_str.replaceAll(regex, "<a href='$0'>$0</a>");
  12. System.out.println(res);
  13. }
  14. }
Success #stdin #stdout 0.04s 711168KB
stdin
Standard input is empty
stdout
<a href='http://w...content-available-to-author-only...e.com?and=value&s=more'>http://w...content-available-to-author-only...e.com?and=value&s=more</a>
<a href='http://10.23.46.134'>http://10.23.46.134</a>
<a href='email@me.at.site.com'>email@me.at.site.com</a>