我想结合几个表达式来获得每行3个不同的结果.
例:
element\data\elements.data|44a0b61d1952973f52ad54cb911c0e3e|33095223
.*?element(?:(?!\|).)* 检索 element\data\elements.data
(?<=\|)(.*?)(?=\|) 检索 44a0b61d1952973f52ad54cb911c0e3e
(?<=\|)[0-9]*\r 检索 33095223
但是对于我来说,我目前正在做3种不同的RegEx,我想将其限制为只有一个来获得我需要的3个结果并将它们设置为不同的变量.
我已经考虑过做一个Dictionary但是那些只允许2个变量,而我需要3个.
我有以下代码:
private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
{
string Elementsfile;
if (File.Exists(Application.StartupPath + "\\checkfiles.lst"))
{
string path = Application.StartupPath + "\\checkfiles.lst";
// Open the file to read from.
foreach (string readText in File.ReadLines(path))
{
var elements = readText.Split('|');
Elementsfile = elements[0];
string HashString = elements[1];
string ByteSize = elements[2];
Console.WriteLine(Elementsfile + HashString + ByteSize);
}
}
string filePath = Elementsfile;
}
Run Code Online (Sandbox Code Playgroud)
我试图声明这些变量:
string Elementsfile = elements[0];
string HashString = elements[1];
string ByteSize = elements[2];
Run Code Online (Sandbox Code Playgroud)
......并在课堂上的其他地方使用它们.
当我尝试使用它们时,例如:string filePath = Elementfile; …