mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-10-27 22:42:38 +01:00
Generic parser fix
git-svn-id: https://subtitleedit.googlecode.com/svn/trunk@2033 99eadd0c-20b8-1223-b5c4-2a2b2df33de2
This commit is contained in:
parent
d4ca1692e2
commit
6b5dece0be
@ -271,9 +271,47 @@ namespace Nikse.SubtitleEdit.Logic
|
|||||||
Paragraph p = null;
|
Paragraph p = null;
|
||||||
var subtitle = new Subtitle();
|
var subtitle = new Subtitle();
|
||||||
var sb = new StringBuilder();
|
var sb = new StringBuilder();
|
||||||
|
|
||||||
|
bool isFirstLineNumber = false;
|
||||||
|
|
||||||
|
int count = -1;
|
||||||
for (int idx = 0; idx < lines.Length; idx++)
|
for (int idx = 0; idx < lines.Length; idx++)
|
||||||
{
|
{
|
||||||
string line = lines[idx];
|
string line = lines[idx];
|
||||||
|
var matches = regexTimeCodes1.Matches(line);
|
||||||
|
if (matches.Count == 0)
|
||||||
|
matches = regexTimeCodes2.Matches(line);
|
||||||
|
if (matches.Count == 2)
|
||||||
|
{
|
||||||
|
string[] start = matches[0].ToString().Split(".,;:".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
|
||||||
|
if (Utilities.IsInteger(start[0]))
|
||||||
|
{
|
||||||
|
int i = int.Parse(start[0]);
|
||||||
|
if (count == -1 && i < 2)
|
||||||
|
count = i;
|
||||||
|
if (count != i)
|
||||||
|
{
|
||||||
|
isFirstLineNumber = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (count > 2)
|
||||||
|
isFirstLineNumber = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int idx = 0; idx < lines.Length; idx++)
|
||||||
|
{
|
||||||
|
string line = lines[idx];
|
||||||
|
|
||||||
|
if (isFirstLineNumber)
|
||||||
|
{
|
||||||
|
while (line.Length > 0 && "0123456789".Contains(line.Substring(0, 1)))
|
||||||
|
{
|
||||||
|
line = line.Remove(0, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var matches = regexTimeCodes1.Matches(line);
|
var matches = regexTimeCodes1.Matches(line);
|
||||||
if (matches.Count == 0)
|
if (matches.Count == 0)
|
||||||
|
Loading…
Reference in New Issue
Block a user