Need help with regular expression to parse URLs



Hello:

I am having trouble figuring out how to write a regular expression to
parse our parts of a url.

For example, I am trying to parse the url
http://jammconsulting.com/jamm/page/test/*/*/*/*.html
into several substrings. The URL should begin with
http://jammconsulting.com/jamm/*/*/
and then have a group of parameters in the form */*
and then end with .html

So, for example, this url:
http://jammconsulting.com/jamm/page/products/Brand/Abc.html

Should give me Brand and Abc as parameters.

I wrote this regular expression:
^http://jammconsulting.com/jamm/[^/]+/[^/]+/([^/]+/[^/]+)*\\.html?

It seems to be working fine for most urls, but it barfed on this one:
http://jammconsulting.com/jamm/page/products/Stuff/Bags-%26-Luggage/Bags-%26-Totes/Backpacks.html

The matcher gives me 1 group with this value: s/Backpacks

I dont understand how that could have happened. I was expecting to
get
two groups:
Stuff/Bags-%26-Luggage
Bags-%26-Totes/Backpacks

Any ideas what went wrong?

Also, is there a way to tell the pattern to further parse the group
into
Stuff and Bags-%26-Luggage separately or should I do that with another
Pattern I apply to the group after I extract it from the main url?

Thanks,
Neil

--
Neil Aggarwal, (281)846-8957, www.JAMMConsulting.com
Will your e-commerce site go offline if you have
a DB server failure, fiber cut, flood, fire, or other disaster?
If so, ask about our geographically redundant database system.
.



Relevant Pages

  • Re: Need help with regular expression to parse URLs
    ... I am having trouble figuring out how to write a regular expression to ... parse our parts of a url. ... You probably don't even have to roll your own regex. ...
    (comp.lang.java.programmer)
  • RE: Check value is number only
    ... > more important than readability, and with extensive testing one can ... > dramatically reduce the risk of such a complicated regular expression from ... > While using a Parse() may be simpler and more readable, ... > invalid values are being dealt with, using the Regex method can be in the ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Need help with regular expression to parse URLs
    ... I am having trouble figuring out how to write a regular expression to ... I am trying to parse the url ... Neil Aggarwal, 846-8957, www.JAMMConsulting.com ... Unlimited Access, Anonymous Accounts, Uncensored Broadband Access ...
    (comp.lang.java.programmer)
  • Re: How to extract variable and its value from URL
    ... You wouldn't even need a regular expression, you can just parse it apart ... on the equals sign and the ampersand (but a regular expression would work ... property to get the query string. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: parse a file into text file
    ... I have to parse this text file. ... You might be able to write a regular expression that will satisfactorily break the data into pieces. ... If and when your employer finds out how careless you are with what is clearly sensitive information, you will be fortunate if you are simply removed from that project. ... Your best bet at the moment is to confess to your employer so that you can begin "damage control", including notification of the doctor and their patients to alert them to the fact that the data has been publicly released. ...
    (microsoft.public.dotnet.languages.csharp)