当出现“?”时,如何在 Charles Proxy 中设置重写规则包括?

发布于 2025-01-07 11:12:56 字数 378 浏览 0 评论 0原文

我正在使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

壹場煙雨 2025-01-14 11:12:56

只是把这个作为答案,因为它让我发疯。为了使用组,您基本上将正则表达式中的内容括在括号组中,如下所示:

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.

放手` 2025-01-14 11:12:56

问号不是占位符,而是量词。因此,/? 表示匹配零个或一个斜杠。

快速搜索 文档

可以启用正则表达式支持,为您的匹配提供 Perl 风格的正则表达式。

那么这应该可以工作

/\?$

$ 将匹配字符串结尾,如果 ? 也应该在字符串结尾之前匹配,只需将其删除即可。

The question mark is not a placeholder, its a quantifier. So, /? means match zero or one slashes.

A quick search for the documentation says

Regex support may be enabled, providing Perl-style regular expressions for your match.

Then this should work

/\?$

The $ would match the string end, if the ? should be matched before the string end also, just remove it.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文