Wiremock与正则表达式不匹配 [英] Wiremock not matching regex
本文介绍了Wiremock与正则表达式不匹配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用Wiremock模拟某些请求及其各自的响应,但是我试图添加一个正则表达式.不幸的是,这只是抛出一个异常,指出请求不匹配.
I'm using wiremock to mock certain requests and their respective response, but I'm trying to add a regex. Unfortunately, this just throws an exception stating that the request was not matched.
{
"request" : {
"method": "GET",
"urlPattern": "/my/service/url?^.*(specificParam.*(M[0-9]{9})).*$"
},
"response": {
...
}
}
我也尝试过
"urlPattern": "/my/service/url\\?^.*(specificParam.*(M[0-9]{9})).*$"
我发送的请求是
/my/service/url?saml2=disabled&filter=specificParam%20eq%20%27M012345678%27
有人知道为什么请求未与映射匹配吗? 预先感谢.
Does anyone have an idea why the request is not being matched to the mapping? Thanks in advance.
推荐答案
您尝试过此方法吗:
{
"request" : {
"method": "GET",
"urlPattern": "^\/my\/service\/url\\?.*(specificParam.*(M[0-9]{9})).*$"
},
"response": {
...
}
}
在此处查看此正则表达式: https://regex101.com/r/B3XACf/1
See this regex here : https://regex101.com/r/B3XACf/1
这篇关于Wiremock与正则表达式不匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文