I'm trying to match urls /api/v1/users... /api/v1/other_stuff...
我正在尝试匹配urls / api / v1 / users ... / api / v1 / other_stuff ...
Except for /api/v1/users/invitation_register
除了/ api / v1 / users / invitation_register
I've been trying to use negative lookbehind
我一直试图使用消极的外观
^\/api.*(?<!\binvitation_register\b)
and several similar constructs and have no idea how to actually do this. Any help would be more then welcome.
和几个类似的结构,并不知道如何实际这样做。任何帮助都会受到欢迎。
1 个解决方案
#1
1
You can use this negative lookahead instead of lookbehind:
您可以使用此负面前瞻而不是lookbehind:
^\/api\/(?!v1\/users\/invitation_register\b).*
(?!v1\/users\/invitation_register\b)
is a negative lookahead that asserts that v1/users/invitation_register
fails after /api/
.
(?!v1 \ / users \ / invitation_register \ b)是一个负面的先行,断言v1 / users / invitation_register在/ api /之后失败。
RegEx演示
If your intended match is always starting with /api/v1/...
then you can use:
如果您的预期匹配始终以/ api / v1 / ...开头,那么您可以使用:
^\/api\/v1\/(?!users\/invitation_register\b).*
which asserts that users/invitation_register
fails after /api/va/
.
在/ api / va /之后断言users / invitation_register失败。
#1
1
You can use this negative lookahead instead of lookbehind:
您可以使用此负面前瞻而不是lookbehind:
^\/api\/(?!v1\/users\/invitation_register\b).*
(?!v1\/users\/invitation_register\b)
is a negative lookahead that asserts that v1/users/invitation_register
fails after /api/
.
(?!v1 \ / users \ / invitation_register \ b)是一个负面的先行,断言v1 / users / invitation_register在/ api /之后失败。
RegEx演示
If your intended match is always starting with /api/v1/...
then you can use:
如果您的预期匹配始终以/ api / v1 / ...开头,那么您可以使用:
^\/api\/v1\/(?!users\/invitation_register\b).*
which asserts that users/invitation_register
fails after /api/va/
.
在/ api / va /之后断言users / invitation_register失败。