02-12-2008, 01:52 AM
i have a global shortcut 'win r' to run selected text anywhere.
what would be the best way to check if selection is an url ?
maybe i don't have to perform some regex when web or
something similar also checks if a string is valid as url.
--
i found this:
what would be the best way to check if selection is an url ?
maybe i don't have to perform some regex when web or
something similar also checks if a string is valid as url.
--
i found this:
Quote:Regex theRegexURL = new Regex("(([a-zA-Z][0-9a-zA-Z+\\-\\.]*?/{0,2}[0-9a-zA-Z;/?&=+$\\.\\-_!~*'()%]+)?(#[0-9a-zA-Z;/?&=+$\\.\\-_!~*'()%]+)?");
If (theRegexURL.IsMatch(theUrlInput))
{
//url matches
}
else
{
//url does not match
}