My goal is a regex that captures {type} and {code} after propertyComplexity in the following string:-
/json/score/propertyComplexity/{type}/{code}
{type} and {code} are variables, could be anything or nothing e.g.
/json/score/propertyComplexity
I have started with the following expression:-
(?<=propertyComplexity)\/(.*)\/|$
But this only captures {type} between the 2 slashes; the end delimiter for the capture groups needs to be slash or end of line.
The regex needs to capture all words after slash after propertyComplexity until terminated by end of line. For example:
/json/score/propertyComplexity/{type}/{code}/{param3}/{param4}
Should yield 4 matches / capture groups; {type}, {code}, {param3}, {param4}
If it helps, this in the context of processing @path attributes in a WADL. The contents of the capture is actually irrelevant as it is the match count that will be used (in a comparison to the count of passed arguments in determining which WADL resource to call).
URL validity is not a requirement.
Matching on or after slash is not necessary when parameters in WADLs will always be encapsulated in {param} placeholders.
So I am simply using the following expression in a preg_match_all() == count($this->passedArgs)
/{(.*?)}/
Thank you everyone who contributed. Answer is being awarded to Jaytea.
{type}
and{code}
, or are they? – Decent Dabbler Nov 29 '17 at 2:23(?<=propertyComplexity)(?:\/([^\/\n]*))?(?:\/([^\/\n]*))?(?:\/|$)
? – Gurmanjot Singh Nov 29 '17 at 3:01