diff --git a/src/libse/SubtitleFormats/CsvNuendo.cs b/src/libse/SubtitleFormats/CsvNuendo.cs index 5905e31c7..6b60ded52 100644 --- a/src/libse/SubtitleFormats/CsvNuendo.cs +++ b/src/libse/SubtitleFormats/CsvNuendo.cs @@ -24,10 +24,16 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats var fine = 0; var errors = 0; var sb = new StringBuilder(); - foreach (var line in lines) + for (var index = 0; index < lines.Count; index++) { + var line = lines[index]; + if (index == 0 && line.StartsWith(" 0 && + if (line.IndexOf(':') > 0 && (CsvLine.IsMatch(line) || CsvLineNoQuotes.IsMatch(line) || CsvLineAllQuotes.IsMatch(line) || diff --git a/src/libse/SubtitleFormats/UnknownSubtitle65.cs b/src/libse/SubtitleFormats/UnknownSubtitle65.cs index 8f6346fcc..f802976be 100644 --- a/src/libse/SubtitleFormats/UnknownSubtitle65.cs +++ b/src/libse/SubtitleFormats/UnknownSubtitle65.cs @@ -8,6 +8,9 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats { public class UnknownSubtitle65 : SubtitleFormat { + + private readonly Regex _regexTimeCodes = new Regex(@"^\d\d:\d\d:\d\d,\d\d:\d\d:\d\d$", RegexOptions.Compiled); + private enum ExpectingLine { TimeCodes, @@ -57,8 +60,6 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) { - var regexTimeCodes = new Regex(@"^\d\d:\d\d:\d\d,\d\d:\d\d:\d\d$", RegexOptions.Compiled); - var paragraph = new Paragraph(); ExpectingLine expecting = ExpectingLine.TimeCodes; _errorCount = 0; @@ -66,7 +67,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats subtitle.Paragraphs.Clear(); foreach (string line in lines) { - if (line.Length == 17 && regexTimeCodes.IsMatch(line)) + if (line.Length == 17 && _regexTimeCodes.IsMatch(line)) { string[] parts = line.Split(new[] { ':', ',', '.', ' ' }, StringSplitOptions.RemoveEmptyEntries); if (parts.Length == 6) diff --git a/src/libse/SubtitleFormats/UnknownSubtitle7.cs b/src/libse/SubtitleFormats/UnknownSubtitle7.cs index 7243e1def..45cc08bf3 100644 --- a/src/libse/SubtitleFormats/UnknownSubtitle7.cs +++ b/src/libse/SubtitleFormats/UnknownSubtitle7.cs @@ -11,6 +11,9 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats /// public class UnknownSubtitle7 : SubtitleFormat { + private readonly Regex _regexTimeCode = new Regex(@"^\d\d:\d\d:\d\d:\d\d ", RegexOptions.Compiled); + private readonly Regex _regexTimeCodeEnd = new Regex(@"^\d\d:\d\d:\d\d:\d\d\t$", RegexOptions.Compiled); + private enum ExpectingLine { TimeStart, @@ -42,9 +45,6 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats public override void LoadSubtitle(Subtitle subtitle, List lines, string fileName) { - var regexTimeCode = new Regex(@"^\d\d:\d\d:\d\d:\d\d ", RegexOptions.Compiled); - var regexTimeCodeEnd = new Regex(@"^\d\d:\d\d:\d\d:\d\d\t$", RegexOptions.Compiled); - var paragraph = new Paragraph(); var expecting = ExpectingLine.TimeStart; _errorCount = 0; @@ -54,7 +54,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats foreach (string line in lines) { count++; - if (regexTimeCode.IsMatch(line)) + if (_regexTimeCode.IsMatch(line)) { string[] parts = line.Substring(0, 11).Split(SplitCharColon, StringSplitOptions.RemoveEmptyEntries); if (parts.Length == 4) @@ -81,7 +81,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats } } } - else if (regexTimeCodeEnd.IsMatch(line) || (count == lines.Count && regexTimeCodeEnd.IsMatch(line + "\t"))) + else if (_regexTimeCodeEnd.IsMatch(line) || (count == lines.Count && _regexTimeCodeEnd.IsMatch(line + "\t"))) { string[] parts = line.Substring(0, 11).Split(SplitCharColon, StringSplitOptions.RemoveEmptyEntries); if (parts.Length == 4)