我想要实现的是显示以needle
字符开头/结尾的行数。
我的代码看起来像这样
case "Starting with":
count = File.ReadLines(openFileDialog1.FileName)
.Count(line => Regex.IsMatch(line, "^" + needle + ".*$"));
break;
case "Ending with":
count = File.ReadLines(openFileDialog1.FileName)
.Count(line => Regex.IsMatch(line, "^.*" + needle + ".*$"));
break;
从找到正确的计数开始,但以不结束。我错过了什么?