C# - 迷失在正则表达式中 - 不同机器上的匹配组

发布于 2024-08-22 14:26:29 字数 655 浏览 3 评论 0原文

我以为我知道如何编写基本的正则表达式。在我的 VS2008、C# 的 x64 电脑上,我正在编写以下正则表达式:

private static readonly Regex TagRegex = new Regex(@"\{QTable\((?<key>(.*?))#(?<query>(.*?))#(?<columns>(.*?))#(?<heading>(.*?))#(?<tbl>(.*?))#(?<headers>(.*?))#(?<row>(.*?))\)\}", RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.ExplicitCapture | RegexOptions.CultureInvariant);

该正则表达式应该找到所有条目,例如:

{QTable(XXX#YYY#ZZZ#111#222#333#444)}

使我能够使用命名组并选择每个值键、查询等... 在我的单元测试+调试模式下,它可以工作,甚至在我自己的 5.1 IIS (x86) 上,我部署了它可以工作的应用程序。 但是,当我在生产服务器上部署时,它不会,在尝试访问命名组时,它会抛出字典中不存在的 ney 。

I've thought I knew how to write basic regex. On my x64 pc in VS2008, C#, I'm writing the following regex:

private static readonly Regex TagRegex = new Regex(@"\{QTable\((?<key>(.*?))#(?<query>(.*?))#(?<columns>(.*?))#(?<heading>(.*?))#(?<tbl>(.*?))#(?<headers>(.*?))#(?<row>(.*?))\)\}", RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.ExplicitCapture | RegexOptions.CultureInvariant);

This regex should find all entries like:

{QTable(XXX#YYY#ZZZ#111#222#333#444)}

Enabling me to use named groups and pick each value key,query etc...
And in my unit test + debug mode it works, even on my own 5.1 IIS (x86) where I deploy the app it works.
However when I deploy on the production server it doesn't, it throws a ney not present in dictionary when trying to access the named groups.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

乱了心跳 2024-08-29 14:26:29

发现错误了。当然是一个完全不相关的地方。正则表达式没有任何问题:)。
如有任何不便,敬请谅解。

Found the error. Of course a completely unrelated place. Nothing wrong with the regex :).
Sorry for any inconvenience.

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