Convert Url String to Hyperlinks
using
System;
using
System.Collections;
using
System.Configuration;
using
System.Data;
using
System.Linq;
using
System.Web;
using
System.Web.Security;
using
System.Web.UI;
using
System.Web.UI.HtmlControls;
using
System.Web.UI.WebControls;
using
System.Web.UI.WebControls.WebParts;
using
System.Xml.Linq;
using
System.IO;
using
System.Text;
public
partial
class
ReplaceString :
System.Web.UI.Page
{
protected
void Page_Load(object
sender,
EventArgs e)
{
string strUrl =
MakeUrl("Hello. This is my site http://www.google.com Please
Visit.");
Response.Write(strUrl);
}
private
static
string MakeUrl(string
input)
{
var work =
input.Split(' ');
var output =
new
StringBuilder(2 *
input.Length);
for (int
i = 0; i <>
{
var element =
work[i];
if
(element.StartsWith("http://"))
{
var site =
element.Replace("http://", "");
element =
"
+ element +
"'>" + site +
"";
}
else
if
(element.StartsWith("www"))
{
var site =
element.Replace("http://", "");
element =
"
+ element +
"'>" + site +
"";
}
else
if
(element.EndsWith(".com"))
{
var site =
element.Replace("http://", "");
element =
"
+ element +
"'>" + site +
"";
}
output.Append(element +
" ");
}
return
output.ToString();
}
}
And the Final output will be like this....
Hello. This is my site http://www.google.com Please Visit.