.NET在其RegularExpression实现中提供了一个Capture集合,因此您可以获取给定重复组的所有实例,而不仅仅是它的最后一个实例.这很好,但我有一个重复的小组与子组,我试图进入子组,因为他们在组下相关,并找不到方法.有什么建议?
我看过其他一些问题,例如:
但我发现没有适用的答案是肯定的("是的,这里是怎么样")或否定的("不,不能做".).
对于一个人为的例子说我有一个输入字符串:
abc d x 1 2 x 3 x 5 6 e fgh
Run Code Online (Sandbox Code Playgroud)
其中"abc"和"fgh"表示我想在较大文档中忽略的文本,"d"和"e"包裹感兴趣的区域,并且在该感兴趣的区域内,"xn [n]"可以重复任何次数.这是我感兴趣的"x"区域中的那些数字对.
所以我正在使用这个正则表达式模式解析它:
.*d (?<x>x ((?<fir>\d+) )?((?<sec>\d+) )?)*?e.*
Run Code Online (Sandbox Code Playgroud)
它将在文档中找到一个匹配项,但多次捕获"x"组.以下是我想在此示例中提取的三对:
但我怎么能得到它们?我可以做以下(在C#中):
using System;
using System.Text;
using System.Text.RegularExpressions;
string input = "abc d x 1 2 x 3 x 5 6 e fgh";
string pattern = @".*d (?<x>x ((?<fir>\d+) )?((?<sec>\d+) )?)*?e.*";
foreach (var x in Regex.Match(input, pattern).Groups["x"].Captures) {
MessageBox.Show(x.ToString());
}
Run Code Online (Sandbox Code Playgroud)
因为我引用组"x"我得到这些字符串:
有很多手动方法可以让WinDBG在没有符号存储的情况下找到mscordacwks.dll(将文件放在某处的路径中,将其放在与windbg.exe相同的文件夹中,将其放在我的Framework\v文件夹中,指定路径WinDBG使用.cordll -lp c:\dacFolder等),但他们都只为我修复它.对于使用我的符号存储的每个人,我需要更普遍地修复它.
我能想到的可能的解决方案是:
问:这些事情中的任何一个都是可能的,或者是否有其他方式我没有考虑解决问题?
在分析.NET进程时,我遇到了(显然很常见的)问题,即psscor2(和sosex)在我的机器上找不到合适的mscordacwks.dll.WinDBG中的错误是:
Failed to load data access DLL, 0x80004005
Verify that 1) you have a recent build of the debugger (6.2.14 or newer)
2) the file mscordacwks.dll that matches your version of mscorwks.dll is
in the version directory
3) or, if you are debugging a dump file, verify that the file
mscordacwks_<arch>_<arch>_<version>.dll is on your symbol path.
4) you are debugging on the same architecture …Run Code Online (Sandbox Code Playgroud)