[UPHPU] regex help

Orson Jones orson.uphpu at afriskito.net
Thu Mar 27 10:07:35 MDT 2008


Orson Jones wrote:
> Wade Preston Shearer wrote:
>> I am trying to match both…
>>
>> http://example.com/a/b
>>
>> …and…
>>
>> http://example.com/a/b/
> 
> ^(.*)/(.*)/?$

Or if you want to also match

http://example.com/a/b/whatever/else/is/out/here/

^(.*)/(.*)/?.*$

Also, you might want to do ([^/]*) instead of (.*)

^([^/]*)/([^/]*)

That one is probably more robust. You don't need an ending $ either unless you want to make sure
nothing is after that.

Orson


More information about the UPHPU mailing list