感谢您的帮助。想了一下之后,我找到了简单的解决方案。
string sampleText = "{'what is' | 'when is'}{BEFORE/2 }{doing | 'to do'}{ NEAR/3 }{'to ensure our' | 'to ensure that' | 'to make sure our' | 'to make sure that our' | 'so our' | 'so that our'}{ BEFORE/4 }{doesn*t | 'does not' | 'will not' | won*t}";
List<List<string>> list = new List<List<string>>();
Match mt = Regex.Match(sampleText, @"\}([^{]*)\{");
string value = sampleText.Replace(mt.Value, "},{");
string[] newArray = value.Split(",".ToCharArray());
foreach (string st in newArray)
{
list.Add(new List<string>(st.Replace("{", "").Replace("}", "").Split('|')));
}
这不是正则表达式服务,你必须自己显示一些努力。你不是在这里寻求帮助,而是为你做功课的人。 – CSharpie
在C#中执行它......这可能在正则表达式中可行,但它会是地狱。 – xanatos
感谢评论xanatos,我是C#的新手,并试图创建一个递归函数来将它们除以{|}。任何参考将有所帮助。 –