I wouldn't recommend using a regex since it is going to be a very
complicated one.
You can always use the string methods, for example:

            const string http = @"http://";;
            const string url = @"http://www.foo.gr/f1/f2/f3/page.htm";;
            string[] folders = url.Substring(http.Length).Split(new
char[] { '/' });

            for (int i = 1; i < folders.Length; i++)
                Console.WriteLine(folders[i]);
            Console.ReadLine();


Hope that helps.


On Oct 5, 6:45 pm, "C." <[email protected]> wrote:
> Hi all,
>
> I need to capture all the folders in a URL with a regex, but I can't
> get the pattern.
>
> I've tried  @"(http://[^/])?/(?<folders>[^/]*)/([^/]*)\.[^/]*", but it
> doesn't work. What pattern can I use to return a capture group that I
> can iterate through and extract all the directories within a URL?
>
> Regards,
>
> Chris

Reply via email to