Merge pull request #1944 from ivandrofly/ocrfrl

[OcrReplaceList] - Remove fruitless replaces.
This commit is contained in:
Nikolaj Olsson 2016-09-07 06:15:50 +02:00 committed by GitHub
commit e07a0340da

View File

@ -182,16 +182,14 @@ namespace Nikse.SubtitleEdit.Core.Dictionaries
{
if (s.Contains(from))
{
string with = _beginLineReplaceList[from];
if (s.StartsWith(from, StringComparison.Ordinal))
s = s.Remove(0, from.Length).Insert(0, _beginLineReplaceList[from]);
s = s.Replace(". " + from, ". " + _beginLineReplaceList[from]);
s = s.Replace("! " + from, "! " + _beginLineReplaceList[from]);
s = s.Replace("? " + from, "? " + _beginLineReplaceList[from]);
s = s.Replace(". " + Environment.NewLine + from, ". " + Environment.NewLine + _beginLineReplaceList[from]);
s = s.Replace("! " + Environment.NewLine + from, "! " + Environment.NewLine + _beginLineReplaceList[from]);
s = s.Replace("? " + Environment.NewLine + from, "? " + Environment.NewLine + _beginLineReplaceList[from]);
s = s.Remove(0, from.Length).Insert(0, with);
s = s.Replace(". " + from, ". " + with);
s = s.Replace("! " + from, "! " + with);
s = s.Replace("? " + from, "? " + with);
if (s.StartsWith("\"" + from, StringComparison.Ordinal) && !from.StartsWith('"'))
s = s.Replace("\"" + from, "\"" + _beginLineReplaceList[from]);
s = s.Replace("\"" + from, "\"" + with);
}
}
sb.AppendLine(s);