RegEx:捕获行动参数

I'm writing a regex to capture the params of an URL REST action. I wrote the following:

(?:\/folder)?\/?([a-zA-Z0-9]+)+

It works great for /folder/one/two/three, and I get one, two and three as result. If I try just /folder/ or /folder I get folder as result, but I don't want to capture it. I'm expecting an empty result.

How can I negate this whole word, in this case?

Here you need to use PCRE verb (*SKIP)(*F),

(?:^(?:\/folder\/?)|^.*$)(*SKIP)(*F)|([a-zA-Z0-9]+)

DEMO

This is because you are capturing folder

try

\/folder\/?([a-zA-Z0-9]+)+
(?:\/folder)?\/?|([a-zA-Z0-9]+)+

Try this.See demo.

http://regex101.com/r/zR2tR4/10