这些是我想要级联拆分字符串的值
List<string> lstsplitWord = new List<string> { ",", "=", "،", "أو", "او", "/", "." };
我已经这样写了,但我认为可能有更优雅的Linq解决方案
foreach(var part1 in srSplitPart.Split(',')) {
foreach(var part2 in part1.Split('=')) {
foreach(var part3 in part2.Split('،')) {
foreach(var part4 in part3.func_Split_By_String("أو")) {
foreach(var part5 in part4.func_Split_By_String("او")) {
foreach(var part6 in part5.Split('/')) {
foreach(var part7 in part6.Split('.')) {
if (part7.Length < 3)
continue;
string srTrans = part7.FixArabic().func_Special_Trim();
srTemp.AppendLine($ "{srTitle} > {srTrans} \t {irTransLevel}");
irTransLevel++;
}
}
}
}
}
}
}
C# .Net 4.6.2
特殊分割函数
public static List<string> func_Split_By_String(this string Sentence, string srReplace)
{
return Sentence.Split(new string[] { srReplace }, StringSplitOptions.None).ToList();
}