当出现“?”时,如何在 Charles Proxy 中设置重写规则包括?
我正在使用 Chales Proxy,到目前为止它对我帮助很大。为了进行测试,我使用重写规则来更改路径参数。只要我不尝试在包含问号的路径上设置重写规则,这效果就很好:
类型:路径
URL示例:/get/article /123456/n/20121208/?
重写规则: /? -> /showAdmin=true/?
我的猜测是问号是一个占位符,我不能将其用作匹配值。我试图逃避它,但也没有成功。
有人知道我该如何解决这个问题吗?关于如何在 Charles 中使用 regEx 的提示也会有所帮助。路径总是相同的。
最好的, 克拉斯
I am using Chales Proxy, and it helped me a lot so far. For testing, I use the rewrite rule to change the Path parameters. This works pretty well, as long as I do not try to set the rewrite rule on a a Path which includes a question mark:
Type: Path
URL sample: /get/article/123456/n/20121208/?
Rewrite rule: /? -> /showAdmin=true/?
My guess is that the questionmark is a placeholder, which I can not use as a match value. I tried to escape it, but it did not work either.
Has anybody got an idea how I can work around it? A hint how to work with regEx in Charles would also help. The path is always the same.
Best,
Klaas
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
只是把这个作为答案,因为它让我发疯。为了使用组,您基本上将正则表达式中的内容括在括号组中,如下所示:
whatever/(.*)/(.*)\.html
然后在替换字段中,您将将该括号组称为 $1、$2 等等,我认为从左到右。
/whatever/$1/$2.json
我相信下面发布的 Stema 应该可以工作,但如果您尝试使用组,这就是您应该如何做的。
Just putting this as an answer because it was driving me nuts. In order to use groups you basically enclose things within the regex in a parentheses group like so:
whatever/(.*)/(.*)\.html
And then in the replace field, you put you refer to that parentheses group as $1, $2 and so on I believe from left to right.
/whatever/$1/$2.json
I believe what stema posted below should work but in case you were trying to use groups, this is how you would do it.
问号不是占位符,而是量词。因此,
/?
表示匹配零个或一个斜杠。快速搜索 文档 说
那么这应该可以工作
$
将匹配字符串结尾,如果?
也应该在字符串结尾之前匹配,只需将其删除即可。The question mark is not a placeholder, its a quantifier. So,
/?
means match zero or one slashes.A quick search for the documentation says
Then this should work
The
$
would match the string end, if the?
should be matched before the string end also, just remove it.