Retrieving URL from Clipboard

  • Thread starter Thread starter shirleylouis
  • Start date Start date
S

shirleylouis

Hi Ppl, Could anyone help me out with retrieving URL from Clipboard
using C#??
 
Hi

Maybe this helps:

System.Windows.Forms.Clipboard.SetData(System.Windows.Forms.DataFormats.Text, "blabla");

System.Windows.Forms.Clipboard.GetData(System.Windows.Forms.DataFormats.Text);


Frank
 
Hi

Maybe this helps:

System.Windows.Forms.Clipboard.SetData(System.Windows.Forms.DataFormats.Tex-t, "blabla");

System.Windows.Forms.Clipboard.GetData(System.Windows.Forms.DataFormats.Tex-t);

Frank





- Show quoted text -

Hi Frank,

Thanks for your suggestion. But Im looking for retrieving URLs. Like
when Im trying to copy text with url, I would like to know if the text
contains any URL or not. And if it does contain, would like to retrive
it from the copied text. I tried retrieving it in html and rtf
formats, using the following statments:

Clipboard.GetDataObject().GetDataPresent(DataFormats.Html);
Clipboard.GetDataObject().GetDataPresent(DataFormats.Rtf);

But Im having trouble in retrieving the URL from both formats. Any
suggestion pertaining to this would be really helpful.

-Shirley
 
Shirley,

I'm not sure about the clipboard part, but it seems that once you
retreived your text (string(s) of data?) from the clipboard, you might
want to use regular expressions to find URLs in that text. You could
start here:

http://www.google.com/search?q=C# regular expression url

The namespace System.Text.RegularExpressions has the stuff you need to
do this in .NET. Basically you use a pattern matcher for URLs and then
iterate through the matches to find all URLs in the text you retreived
from the clipboard.

Regards, good luck,
Jeroen
 
Shirley,

I'm not sure about theclipboardpart, but it seems that once you
retreived your text (string(s) of data?) from theclipboard, you might
want to use regular expressions to find URLs in that text. You could
start here:

http://www.google.com/search?q=C# regular expression url

The namespace System.Text.RegularExpressions has the stuff you need to
do this in .NET. Basically you use a pattern matcher for URLs and then
iterate through the matches to find all URLs in the text you retreived
from theclipboard.

Regards, good luck,
Jeroen


Thanks for your help Jeroen. I retrived the URLs in Html format
itself.

-Shirley
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top