Automatically Hyperlink URLs and E-Mail Addresses in
ASP.NET Pages with C#
Answer / guest
using System.Text.RegularExpressions;
The second step is to detect a URL:
Regex urlregex = new Regex(@"(http:\/\/([\w.]+\/?)\S*)",
RegexOptions.IgnoreCase|RegexOptions.Compiled);
Here is how to detect an e-mail address:
Regex emailregex = new
Regex(@"([a-zA-Z_0-9.-]+\@[a-zA-Z_0-9.-]+\.\w+)",
RegexOptions.IgnoreCase|RegexOptions.Compiled);
private void Button1_Click(object sender, System.EventArgs
e)
{
string strContent = InputTextBox.Text;
Regex urlregex = new Regex(@"(http:\/\/([\w.]+\/?)\S*)",
RegexOptions.IgnoreCase|
RegexOptions.Compiled);
strContent = urlregex.Replace(strContent,
"");
Regex emailregex = new
Regex(@"([a-zA-Z_0-9.-]+\@[a-zA-Z_0-9.-]+\.\w+)",
RegexOptions.IgnoreCase| RegexOptions.Compiled);
strContent = emailregex.Replace(strContent, "");
lbContent.Text += ""+strContent;
}
Is This Answer Correct ? | 1 Yes | 0 No |
Can you declare an array of mixed Types?
How to Create Files by Using the FileInfo Class?
how to change password in .net with c # with ado.net and also SQL server 2008 change password
IS Array list is generic or non generic
. Write a program to print the following outputs using for loops $ $ $ $ $ $ $ $ $ $ $ $ $ $ $
Write a program. there are 1..n numbers placed in an array in random fashion with one integer missing. find the missing number.
program for straight line(y=mx+c)
Write a program to convert postfix expression to infix expression.
program for string reverse(eg:- i am boy -> boy am i)
8 Answers Black Pepper, Infosys, Mind Tree,
How to use ASP.NET 2.0's TreeView to Display Hierarchical Data?
How to export 2 datatables of a single dataset to 2 different worksheets of a single MSExcel file ?
Write a program to input an integer and - display the reverse - display the sum of each digit - should include logic that considers the input number as any number of digits long