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 |
write a Program to copy the string using switch case.
program for straight line(y=mx+c)
Coding for Manipulate XML File Data Using C#?
Event Handling in C# Triggering a Button
c# coding for a program that takes a 3 digit number n and finds out whether the number 2^n + 1 is prime, or if it is not prime find out its factors not using the Big-integer and Exponential Function's.
how can i split sting in textbox in windows application using c# .net
How to find No of classes,Packages,No of Methods per Classes and Depth of Inheritance for selecting source code in windows form application using c# .net? (Source code is input Program. It may be Java or .net) Please help me..) Thanks..)
how to get the table names via c sharp and column names also?
Code for Searching for Multiple Matches with the MatchCollection Class?
How to use ASP.NET 2.0's TreeView to Display Hierarchical Data?
program to reverse the order of digits in a given number of any length.
how do i copy textbox contents of 1 form to another form