On Thu, Mar 27, 2008 at 6:07 AM, Tyler Gee <[EMAIL PROTECTED]> wrote: > On Thu, Mar 27, 2008 at 5:58 AM, Wade Preston Shearer > <[EMAIL PROTECTED]> wrote: > > I am trying to match both… > > > > http://example.com/a/b > > > > …and… > > > > http://example.com/a/b/ > > > > > > ^(.*)/(.*)$ > > Regexp are greedy by default and they always return the first match, > so your first (.)
This should have said, "your first (.*)" > will burn to the end of the string and then batch > the '/' and then there is nothing to match the (.*)$. The solutions > are mailed back just make the last '/' optional (0 or 1 occurence) > which means when the first regexp doesn't match, it tries again not > being greedy and this time matches the optional '/' > > > > > > …works for the first and… > > > > ^(.*)/(.*)/$ > > > > > > …works for the second, but I can't find a solution that matches both. > > Shouldn't the first match both because I am stopping after the "b" and > > not caring about thing else after that? > > > > > _______________________________________________ > > > > UPHPU mailing list > > [email protected] > > http://uphpu.org/mailman/listinfo/uphpu > > IRC: #uphpu on irc.freenode.net > > > > > > -- > ~Tyler > -- ~Tyler _______________________________________________ UPHPU mailing list [email protected] http://uphpu.org/mailman/listinfo/uphpu IRC: #uphpu on irc.freenode.net
