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?
Write a function which accepts a sentence as input parameter.Each word in that sentence is to be reversed. Space should be there between each words.Return the sentence with reversed words to main function and produce the required output. for eg:- i/p: jack jill jung kill o/p: kcaj llij gnuj llik
How to Create a Treeview Menu in ASP.NET with C#?
Code for Reading and writing from a file?
Event Handling in C# Triggering a Button
Automatically Hyperlink URLs and E-Mail Addresses in ASP.NET Pages with C#
Write a program to count the number of characters, number of words, number of line in 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
Coding for using Nullable Types in C#?
program for addition of fraction(M/N + P/Q = Y/Z)
Give the code for Handling Mouse Events?
program for string reverse(eg:- i am boy -> boy am i)
8 Answers Black Pepper, Infosys, Mind Tree,