110,533
社区成员
发帖
与我相关
我的任务
分享
string pattern = @"(?i)((.*)?\|(.*)?){5}";
string result = Regex.Match(tempStr, pattern).Value;
List<string> temp_list = new List<string>() {
"aaa|bbb|dd||123|12d$",
"|a|b|||",
"|||||",
"1|2|3|4|",
""
};
foreach (string item in temp_list)
{
if (Regex.IsMatch(item, pattern))
{
//符合
}
/*
* true
* true
* true
* false
* false
*/
}