Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private static string RemoveEmptyFontTag(string text)
- {
- var startFontIdx = text.IndexOf("<font ", StringComparison.OrdinalIgnoreCase);
- if (startFontIdx < 0)
- {
- return text;
- }
- // find the first font-close tag after the font-open
- var endFontIdx = text.IndexOf("</font>", startFontIdx + 6, StringComparison.OrdinalIgnoreCase);
- if (endFontIdx < startFontIdx)
- {
- return text;
- }
- var startFontCloseIdx = text.LastIndexOf('>', endFontIdx - 1);
- // <font color="#ffff00"></font>
- if (startFontCloseIdx + 1 == endFontIdx)
- {
- return text.Remove(startFontIdx, (endFontIdx + 7) - startFontIdx);
- }
- // <font color="#ffff00"> </font>
- for (int i = startFontCloseIdx + 1; i < endFontIdx; i++)
- {
- var ch = text[i];
- if (!(char.IsControl(ch) || char.IsWhiteSpace(ch)))
- {
- return text;
- }
- }
- return text.Remove(startFontIdx, (endFontIdx + 7) - startFontIdx)
- .Insert(startFontIdx, " ");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement