Got more questions? Find advice on: ASP | SQL | XML | Windows
in Search
Welcome to RegexAdvice Sign in | Join | Help

get complete url except last part .html

Last post 07-17-2009, 5:39 AM by komandin.alexander. 1 replies.
Sort Posts: Previous Next
  •  06-17-2009, 11:27 PM 54056

    get complete url except last part .html

    Hi

     

    I'm working in VS.net using C# and trying to learn regular expressions.  I have a simple project (well seems simple) which I let the user upload from URL, now after then upload from the URL I also import or upload the stylesheet.  I have everything except that I need to get the domain and every subfolder and attach the filename of the stylesheet at the end, here is my example of the outcome:

     URL: http://www.domain.com/test.html or http://www.domain.com/subfolder/test.html

    so the outcome i would like:

     http://www.domain.com/ or http://www.domain.com/subfolders/

     

    I have done some searching through the threads and found this expression:

    (?<=://)[^/]+(?=/)  but it only returns the domain and thats it.

    Help? Thanks in advance

     

  •  07-17-2009, 5:39 AM 55231 in reply to 54056

    Re: get complete url except last part .html

    text:

    http://www.domain.com/test.html
    http://www.domain.com/subfolder/test.html
    http://www.domain.com/one/two/test.html

    Regex:

    http://[\w\.-]+.*/

    Result:

    http://www.domain.com/
    http://www.domain.com/subfolder/
    http://www.domain.com/one/two/

     

     

    More examples:

    http://komandin.org/regex/regex_view.html



View as RSS news feed in XML