php - Regexp : repeat matching -


I am trying to create a regular expression in which some of them can be 0 ... X times: < /

/ cat1 / var1

/ cat2 / var2

/ cat3 / var3

This is what I have so far received:

  ((cat1 | cat2 | cat3) / (? P & lt; var & gt; W +)) *   

In this sample string it matches only the first event: http://url.dev/cat1/aaaaa / cat1 / Bbbbb / cat2 / ccccc

There are two cat1 events in this sample too, I know Ahunga whether it is possible to harvest the two values.

Some samples of what I want to do:

http://url.dev/cat1/aaaaa/cat1/bbbbb/cat2/ccccc/cat3/ Dev / cat2 / aaaaa / cat3 / bbbbb

would you use it only

  (cat \ d / (? P & lt; var \ d & gt; \ w +)) *   

All this cat / var

[edit]

It was: >

Comments