James Teare
James Teare

Reputation: 372

Regex for a URI / URL

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?

Upvotes: 0

Views: 937

Answers (1)

m.edmondson
m.edmondson

Reputation: 30872

Try this:

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

You may need to escape some characters again.

Upvotes: 1

Related Questions