Java code
Import java. util. regex. Matcher;
Import java. util. regex. Pattern;
Public class HtmlTag {
Public static void main (String [] args ){
String str = "this is a url link http://www-test.company.com/view/1_2.html? A = % B8 & f = % E4 + % D3 # To convert td to clickable ";
String regex = "(http: | https :) // [^ [A-Za-z0-9 \\._\\? % & + \-=/#] * ";
Pattern pattern = Pattern. compile (regex );
Matcher matcher = pattern. matcher (str );
StringBuffer result = new StringBuffer ();
While (matcher. find ()){
StringBuffer replace = new StringBuffer ();
Replace. append ("<a href = \" "). append (matcher. group ());
Replace. append ("\" target = \ "_ blank \"> click to open the link </a> ");
Matcher. appendReplacement (result, replace. toString ());
}
Matcher. appendTail (result );
System. out. println (str );
System. out. println (result );
}
}
Author "wsy495"