V
Vincent Mouton
Hi,
I am trying to build a regex expression that holds two expressions, and
I'd like the main expression to match if at least one of those two
sub-expressions match, or if they both match. I am using this to parse
URL's.
Example URL's:
/brand/hpe/category/wi (catch this)
/brand/hpe (catch this)
/category/wi/brand/hpe (catch this)
/category/wi (catch this)
/otherpage (do not catch this)
the only thing i came up with is this huge thing:
(\/brand\/(\w)+)|(\/category\/(\w)+)|(\/category\/(\w)+\/brand\/(\w)+)|(\/brand\/(\w)+\/category\/(\w)+)
So a URL is built up of a brand section, a category section or both. Is
there a better way to capture those 4 possible URL's than the expression
I came up with?
thanks a lot,
Vincent
I am trying to build a regex expression that holds two expressions, and
I'd like the main expression to match if at least one of those two
sub-expressions match, or if they both match. I am using this to parse
URL's.
Example URL's:
/brand/hpe/category/wi (catch this)
/brand/hpe (catch this)
/category/wi/brand/hpe (catch this)
/category/wi (catch this)
/otherpage (do not catch this)
the only thing i came up with is this huge thing:
(\/brand\/(\w)+)|(\/category\/(\w)+)|(\/category\/(\w)+\/brand\/(\w)+)|(\/brand\/(\w)+\/category\/(\w)+)
So a URL is built up of a brand section, a category section or both. Is
there a better way to capture those 4 possible URL's than the expression
I came up with?
thanks a lot,
Vincent