Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static string FixEllipsesStartHelper(string text)
- {
- if (string.IsNullOrEmpty(text) || text.Trim().Length < 4 || !(text.Contains("..", StringComparison.Ordinal) || text.Contains(". .", StringComparison.Ordinal)))
- return text;
- const string preChars = ">-\"”“'‘`´¶#♪♫¿¡—";
- var pre = string.Empty;
- text = text.TrimStart();
- for (int i = 0; i < 3; i++)
- {
- while (text.Length > 1 && preChars.Contains(text[0]))
- {
- pre += text[0];
- text = text.Substring(1).TrimStart();
- }
- //<font color="#000000">
- if (text.StartsWith("<font", StringComparison.OrdinalIgnoreCase) && text.IndexOf('>', 5) >= 5)
- {
- var idx = text.IndexOf('>', 5);
- if (idx >= 5)
- {
- pre += text.Substring(0, text.IndexOf('>') + 1);
- text = text.Substring(idx + 1).TrimStart();
- }
- }
- // <b>, <u>, <i>
- while (text.Length > 3 && text[0] == '<' && text[2] == '>')
- {
- pre += "<" + text[1] + ">";
- text = text.Substring(3).TrimStart();
- }
- text = text.TrimStart('.', ' ');
- }
- text = text.Replace(" ", " ");
- // WOMAN 2: <i>...24 hours a day at BabyC.</i>
- var index = text.IndexOf(':');
- if (index >= 1 && !Utilities.IsBetweenNumbers(text, index) &&
- (text.Contains("..", StringComparison.Ordinal)|| text.Contains(". .", StringComparison.Ordinal)))
- {
- pre += text.Substring(0, index + 1);
- text = text.Substring(index + 1).TrimStart();
- text = FixEllipsesStartHelper(text);
- }
- if (pre.Length > 0 && !" >\"".Contains(pre[pre.Length - 1]))
- pre += " ";
- return pre + text;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement