ASP.Net Find url within a string using Regular Expressions
By [)ia6l0 iii
Use this code snippet to find url's in a string.
Regex urlRegEx = new Regex("http(s)?://([\w+?\.\w+])+([a-zA-Z0-9\~\!\@\#\$\%\^\&\*\(\)_\-\=\+\\\/\?\.\:\;\'\,]*)?"
, RegexOptions.IgnoreCase);
MatchCollection urls = regx.Matches(inputText);
foreach (Match url in urls)
{
...
}
Related FAQs
Use the ColorTransalator to convert a html string or the color name to a valid Color object.
C# 4.0 provides us a new type of generics - Tuples
You can use the ScriptManager to find if a postback is for a partial rendering of a page. The ScriptManager provides us the IsInAsyncPostBack property to determine this.
You can check the contenttype of the request, and figure out if the request is an JSon request
You can check the contenttype of the request, and figure out if the request is an Ajax request
You can truncate the file paths using the Shell LightWeight library.
ASP.Net Find url within a string using Regular Expressions (1033 Views)