我正在搜索多个文本文件,并且有一些行丢失,我试图用" NO DATA"
var GetNotes = new Regex(@"(?<=[A-Z0-9/jfc]</B>)([\s\Sa-z]*?[\s\S])(?=<tr><td>|<tr class=disabled>|</table><h4 class|[£])").Matches(set);
foreach (var Notes in GetNotes)
{
String NotesAtLine1 = File.ReadLines(FractionTwoData).ElementAtOrDefault(NotesPositionLine);
string NotesToString = Notes.ToString();
string replacement = Regex.Replace(NotesToString, @"\t|\n|\r", "");
File.AppendAllText(NotesData, NotesAtLine1 + replacement + Environment.NewLine);
NotesPositionLine++;
if (DebugChechBox.Checked == true)
{
Console.WriteLine("Notes are " + replacement);
NotesBox.Text = replacement;
}
}
如果它找到我的正则表达式它工作正常,但如果它不存在我该如何让它做某事?