mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-10-27 22:42:38 +01:00
[internal] - add new method to GetLineWithPerhapsOnlyNumbers
This commit is contained in:
parent
fb5145d209
commit
79f97e612d
@ -133,7 +133,7 @@ namespace Nikse.SubtitleEdit.Core
|
|||||||
for (int idx = 0; idx < lines.Length; idx++)
|
for (int idx = 0; idx < lines.Length; idx++)
|
||||||
{
|
{
|
||||||
string line = lines[idx];
|
string line = lines[idx];
|
||||||
string lineWithPerhapsOnlyNumbers = line.Replace(" ", string.Empty).Replace(".", string.Empty).Replace(",", string.Empty).Replace("\t", string.Empty).Replace(":", string.Empty).Replace(";", string.Empty).Replace("{", string.Empty).Replace("}", string.Empty).Replace("[", string.Empty).Replace("]", string.Empty).Replace("-", string.Empty).Replace(">", string.Empty).Replace("<", string.Empty);
|
string lineWithPerhapsOnlyNumbers = GetLineWithPerhapsOnlyNumbers(line);
|
||||||
bool allNumbers = lineWithPerhapsOnlyNumbers.Length > 0;
|
bool allNumbers = lineWithPerhapsOnlyNumbers.Length > 0;
|
||||||
foreach (char c in lineWithPerhapsOnlyNumbers)
|
foreach (char c in lineWithPerhapsOnlyNumbers)
|
||||||
{
|
{
|
||||||
@ -244,7 +244,7 @@ namespace Nikse.SubtitleEdit.Core
|
|||||||
for (int idx = 0; idx < lines.Length; idx++)
|
for (int idx = 0; idx < lines.Length; idx++)
|
||||||
{
|
{
|
||||||
string line = lines[idx];
|
string line = lines[idx];
|
||||||
string lineWithPerhapsOnlyNumbers = line.Replace(" ", string.Empty).Replace(".", string.Empty).Replace(",", string.Empty).Replace("\t", string.Empty).Replace(":", string.Empty).Replace(";", string.Empty).Replace("{", string.Empty).Replace("}", string.Empty).Replace("[", string.Empty).Replace("]", string.Empty).Replace("-", string.Empty).Replace(">", string.Empty).Replace("<", string.Empty);
|
string lineWithPerhapsOnlyNumbers = GetLineWithPerhapsOnlyNumbers(line);
|
||||||
bool allNumbers = lineWithPerhapsOnlyNumbers.Length > 0;
|
bool allNumbers = lineWithPerhapsOnlyNumbers.Length > 0;
|
||||||
foreach (char c in lineWithPerhapsOnlyNumbers)
|
foreach (char c in lineWithPerhapsOnlyNumbers)
|
||||||
{
|
{
|
||||||
@ -468,10 +468,11 @@ namespace Nikse.SubtitleEdit.Core
|
|||||||
Paragraph p = null;
|
Paragraph p = null;
|
||||||
var subtitle = new Subtitle();
|
var subtitle = new Subtitle();
|
||||||
var sb = new StringBuilder();
|
var sb = new StringBuilder();
|
||||||
|
char[] SplitChars = { ' ', '\t' };
|
||||||
for (int idx = 0; idx < lines.Length; idx++)
|
for (int idx = 0; idx < lines.Length; idx++)
|
||||||
{
|
{
|
||||||
string line = lines[idx];
|
string line = lines[idx];
|
||||||
string lineWithPerhapsOnlyNumbers = line.Replace(" ", string.Empty).Replace(".", string.Empty).Replace(",", string.Empty).Replace("\t", string.Empty).Replace(":", string.Empty).Replace(";", string.Empty).Replace("{", string.Empty).Replace("}", string.Empty).Replace("[", string.Empty).Replace("]", string.Empty).Replace("-", string.Empty).Replace(">", string.Empty).Replace("<", string.Empty);
|
string lineWithPerhapsOnlyNumbers = GetLineWithPerhapsOnlyNumbers(line);
|
||||||
bool allNumbers = lineWithPerhapsOnlyNumbers.Length > 0;
|
bool allNumbers = lineWithPerhapsOnlyNumbers.Length > 0;
|
||||||
foreach (char c in lineWithPerhapsOnlyNumbers)
|
foreach (char c in lineWithPerhapsOnlyNumbers)
|
||||||
{
|
{
|
||||||
@ -480,7 +481,7 @@ namespace Nikse.SubtitleEdit.Core
|
|||||||
}
|
}
|
||||||
if (allNumbers && lineWithPerhapsOnlyNumbers.Length > 5)
|
if (allNumbers && lineWithPerhapsOnlyNumbers.Length > 5)
|
||||||
{
|
{
|
||||||
string[] arr = line.Replace('-', ' ').Replace('>', ' ').Replace('{', ' ').Replace('}', ' ').Replace('[', ' ').Replace(']', ' ').Trim().Split(new[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
|
string[] arr = line.Replace('-', ' ').Replace('>', ' ').Replace('{', ' ').Replace('}', ' ').Replace('[', ' ').Replace(']', ' ').Trim().Split(SplitChars, StringSplitOptions.RemoveEmptyEntries);
|
||||||
if (arr.Length == 2)
|
if (arr.Length == 2)
|
||||||
{
|
{
|
||||||
string[] start = arr[0].Trim().Split(ExpectedSplitChars, StringSplitOptions.RemoveEmptyEntries);
|
string[] start = arr[0].Trim().Split(ExpectedSplitChars, StringSplitOptions.RemoveEmptyEntries);
|
||||||
@ -572,10 +573,11 @@ namespace Nikse.SubtitleEdit.Core
|
|||||||
Paragraph p = null;
|
Paragraph p = null;
|
||||||
var subtitle = new Subtitle();
|
var subtitle = new Subtitle();
|
||||||
var sb = new StringBuilder();
|
var sb = new StringBuilder();
|
||||||
|
char[] SplitChar = new[] { ' ' };
|
||||||
for (int idx = 0; idx < lines.Length; idx++)
|
for (int idx = 0; idx < lines.Length; idx++)
|
||||||
{
|
{
|
||||||
string line = lines[idx];
|
string line = lines[idx];
|
||||||
string lineWithPerhapsOnlyNumbers = line.Replace(" ", string.Empty).Replace(".", string.Empty).Replace(",", string.Empty).Replace("\t", string.Empty).Replace(":", string.Empty).Replace(";", string.Empty).Replace("{", string.Empty).Replace("}", string.Empty).Replace("[", string.Empty).Replace("]", string.Empty).Replace("-", string.Empty).Replace(">", string.Empty).Replace("<", string.Empty);
|
string lineWithPerhapsOnlyNumbers = GetLineWithPerhapsOnlyNumbers(line);
|
||||||
bool allNumbers = lineWithPerhapsOnlyNumbers.Length > 0;
|
bool allNumbers = lineWithPerhapsOnlyNumbers.Length > 0;
|
||||||
foreach (char c in lineWithPerhapsOnlyNumbers)
|
foreach (char c in lineWithPerhapsOnlyNumbers)
|
||||||
{
|
{
|
||||||
@ -584,7 +586,7 @@ namespace Nikse.SubtitleEdit.Core
|
|||||||
}
|
}
|
||||||
if (allNumbers && lineWithPerhapsOnlyNumbers.Length > 5)
|
if (allNumbers && lineWithPerhapsOnlyNumbers.Length > 5)
|
||||||
{
|
{
|
||||||
string[] arr = line.Replace('-', ' ').Replace('>', ' ').Replace('{', ' ').Replace('}', ' ').Replace('[', ' ').Replace(']', ' ').Trim().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
|
string[] arr = line.Replace('-', ' ').Replace('>', ' ').Replace('{', ' ').Replace('}', ' ').Replace('[', ' ').Replace(']', ' ').Trim().Split(SplitChar, StringSplitOptions.RemoveEmptyEntries);
|
||||||
if (arr.Length == 2)
|
if (arr.Length == 2)
|
||||||
{
|
{
|
||||||
string[] start = arr[0].Trim().Split(ExpectedSplitChars, StringSplitOptions.RemoveEmptyEntries);
|
string[] start = arr[0].Trim().Split(ExpectedSplitChars, StringSplitOptions.RemoveEmptyEntries);
|
||||||
@ -658,6 +660,11 @@ namespace Nikse.SubtitleEdit.Core
|
|||||||
return subtitle;
|
return subtitle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static string GetLineWithPerhapsOnlyNumbers(string line)
|
||||||
|
{
|
||||||
|
return line.Replace(" ", string.Empty).Replace(".", string.Empty).Replace(",", string.Empty).Replace("\t", string.Empty).Replace(":", string.Empty).Replace(";", string.Empty).Replace("{", string.Empty).Replace("}", string.Empty).Replace("[", string.Empty).Replace("]", string.Empty).Replace("-", string.Empty).Replace(">", string.Empty).Replace("<", string.Empty);
|
||||||
|
}
|
||||||
|
|
||||||
private static TimeCode DecodeTime(string[] parts)
|
private static TimeCode DecodeTime(string[] parts)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
Loading…
Reference in New Issue
Block a user