0

I am currently searching through an HTML page for a specific link, at the moment I have a regex as follows that picks up a generic URI:

Regex regex = new Regex(@"(https?|ftp|file)\://[A-Za-z0-9\.\-]+(/[A-Za-z0-9\?\&\=;\+!'\(\)\*\-\._~%]*)*");

Although there are several links in the HTML so it picks out the first one, where as the link I want to extract is as follows:

http://*.*.com/dlp/*/*/*

How could this be achieved using a regex?

James Teare
  • 372
  • 1
  • 12
  • 23
  • Any attempt at a general solution using regular expressions is going to fail. http://stackoverflow.com/a/1732454/56778. But a search for "regex url" on this site will give you plenty of attempts that succeed to varying degrees. – Jim Mischel Jun 12 '12 at 17:10

1 Answers1

1

Try this:

http\://[A-Za-z0-9\.\-]+\.com/dlp[A-Za-z0-9\.\-/]*

You may need to escape some characters again.

m.edmondson
  • 30,382
  • 27
  • 123
  • 206