From e2ea2c87e2f7e69e8df28b0f86d8f051dadd653d Mon Sep 17 00:00:00 2001 From: Ivandro Ismael Date: Wed, 7 Sep 2016 04:21:10 +0100 Subject: [PATCH] [OcrReplaceList] - Remove fruitless replaces. --- libse/Dictionaries/OcrFixReplaceList.cs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/libse/Dictionaries/OcrFixReplaceList.cs b/libse/Dictionaries/OcrFixReplaceList.cs index 4b451c0e4..0baccf195 100644 --- a/libse/Dictionaries/OcrFixReplaceList.cs +++ b/libse/Dictionaries/OcrFixReplaceList.cs @@ -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);