简体   繁体   中英

How to match a recurring group

I search quite a bit on google for this answer. Perhaps it is easy but in my case I did not manage to find the solution.

How to match and parse it in groups with regex service-page-name/32/54/regular/superize

I am trying to use preg_match and I would like to have

groupe 1 -> service-page-name

groupe 2 -> /32

groupe 3 -> /54

groupe 4 -> /regular

groupe 5 -> /supersize

Important obviously there is the possibility to add n numbers of parameters not just the 4 we have here in addition of the page.

Thanks

here's solution:

preg_match_all("/(\/?[\w-]+)/", $input_lines, $output_array);

you can check results of this pattern & tweak it in realtime here: https://www.phpliveregex.com/p/oD5

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM