我的正则表达式在 spring-cloud-gateway 中无效
My regex does not effective in spring-cloud-gateway
我正在学习 spring-cloud-gateway,当我练习 predicates
时,我想尝试一些正则表达式,如下所示:
spring:
cloud:
gateway:
routes:
- id: after_route
uri: http://www.google.com/
predicates:
- Cookie=token, hello*
我认为hello*
会匹配hello
、helloa
、helloaaaaa
...,但是当我用curl --cookies ...
测试时,它只匹配hello
,为什么 helloa
和 helloaaaaa
没有正确匹配?
spring 云 application.yml 中的正则表达式是否需要一些更改?
我与 yaml 或网关没有任何关系,只是 java 正则表达式
"helloaaaa".matches("hello*") // returns false.
但这行得通
"helloaaaa".matches("hello.*") // returns true.
模式javadoc说X* matches X, zero or more times
所以你的正则表达式会匹配 "hellooooo"
"hellooooo".matches("hello*") // returns true.
我正在学习 spring-cloud-gateway,当我练习 predicates
时,我想尝试一些正则表达式,如下所示:
spring:
cloud:
gateway:
routes:
- id: after_route
uri: http://www.google.com/
predicates:
- Cookie=token, hello*
我认为hello*
会匹配hello
、helloa
、helloaaaaa
...,但是当我用curl --cookies ...
测试时,它只匹配hello
,为什么 helloa
和 helloaaaaa
没有正确匹配?
spring 云 application.yml 中的正则表达式是否需要一些更改?
我与 yaml 或网关没有任何关系,只是 java 正则表达式
"helloaaaa".matches("hello*") // returns false.
但这行得通
"helloaaaa".matches("hello.*") // returns true.
模式javadoc说X* matches X, zero or more times
所以你的正则表达式会匹配 "hellooooo"
"hellooooo".matches("hello*") // returns true.