[UPHPU] regex help for a rewrite

justin justin at justinhileman.info
Fri Aug 22 14:54:32 MDT 2008


On Fri, Aug 22, 2008 at 4:50 PM, justin <justin at justinhileman.info> wrote:
> try this:
>
> ^(?!.*/-/.*/-/)((.+?)/-/(.*)|(.*))$
>
> matches:
>
> 0 - the full line (if it meets the requirements)
> 1 - everything before the /-/, if /-/ exists.
> 2 - everything after the /-/, if /-/ exists and if there is anything after it.
>

sorry, i gave you the wrong version. should have been this:

^(?!.*/-/.*/-/)((.+?)/-/(.*)|.*)$

the last set of parentheses were unnecessary, since match 3 == match 0
any time match 3 != ''.

i'm also assuming you don't actually need a match for the /-/ string.
if you do, go ahead and wrap that in parentheses.

justin
-- 
http://justinhileman.com


More information about the UPHPU mailing list