My URL looks like this:
domain.com/12345/some-product-category
and with the optional pagination:
domain.com/12345-2/some-product-category
so far my pattern looks like this:
^([0-9]{5})(-[0-9]+)?/([_0-9a-z-]*)
but the capture {R:2} return "-2" and not "2" as wanted... How do I fix this?
您可以使用如下表达式:
^(\d{5})(?:-(\d+))?/([\w-]*)
because you've placed in your group -[0-9]+
and not [0-9]+
. You should take off minus sign from group.
Try this regex ^([0-9]{5})(-([0-9]+))?/([_0-9a-z-]*)
and take group 3.
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.