Author Topic: Matching URLs with a possible extra subdirectory - Regular Expression Help?  (Read 536 times)

I am trying to match two types of URL in these formats:

http://example.com/First/Second/File.Ext
http://example.com/First/Second/Third/File.Ext

While I could simply encompass the URL by its containing text, I require the individual portions of the URL to rearrange. As such, the regular expression must match each portion. Another issue is the URLs are all received on a single line, so optional text ((.*?/)? for Third/) causes it to match across to the next URL. I also don't have the option of running multiple scans, so I can't just extract all full URLs and go from there sadly.

So basically, I need to retrieve First, Second, and if Third exists, that as well. Otherwise, don't keep looking for Third into the next URL.
« Last Edit: January 09, 2014, 07:23:56 AM by MegaScientifical »