Possible Duplicate:
regex for URL including query string
I have a text or message.
Hey! try this http://www.test.com/test.aspx?id=53
Our requirement is to get link from a text.We are using following code
List<string> list = new List<string>();
Regex urlRx = new
Regex(@"(?<url>(http:|https:[/][/]|www.)([a-z]|[A-Z]|[0-9]|[/.]|[~])*)",
RegexOptions.IgnoreCase);
MatchCollection matches = urlRx.Matches(message);
foreach (Match match in matches)
{
list.Add(match.Value);
}
return list;
It gives url but not the complete one.Output of the code is
http://www.test.com/test.aspx
But we need complete url like
http://www.test.com/test.aspx?id=53
Please suggest how to resolve that issue.Thanks in advance.
Extract the Hyperlink URL with a Keyboard ShortcutSelect the cell containing the hyperlink and press Ctrl + K to open the Edit Hyperlink menu. This will open the Edit Hyperlink menu and you can copy and paste the URL from the Address just like before.
Try this regex, returns the query string also
(http|ftp|https)://([\w+?\.\w+])+([a-zA-Z0-9\~\!\@\#\$\%\^\&\*\(\)_\-\=\+\\\/\?\.\:\;\'\,]*)?
You can test it on gskinner
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With