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?
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.
c# code to Count number of 1's in a given range of integer (0 to n)
How to pass multiple rows from one gridview to another gridview after clicking the checkbox.
How to Create a Treeview Menu in ASP.NET with C#?
How to Create Files by Using the FileInfo Class?
how to get the table names via c sharp and column names also?
Write a function which accepts list of nouns as input parameter and return the same list in the plural form. Conditions: i) if last letter is r then append s ii) if word ends with y then replace it by ies iii) call this function in main() and produce the required output. for eg:- if chair is input it should give chairs as output.
How to use ASP.NET 2.0's TreeView to Display Hierarchical Data?
how do i copy textbox contents of 1 form to another form
program for string reverse(eg:- i am boy -> boy am i)
8 Answers Black Pepper, Infosys, Mind Tree,
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..)