Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- string RemoveWrapped(string inp)
- {
- var lastIndex = inp.IndexOf("</i>", StringComparison.Ordinal);
- if (lastIndex < 0) return inp;
- var index = inp.IndexOf("<i>", 0, lastIndex, StringComparison.Ordinal);
- if (index < 0) return inp;
- var nearestClosingIndex = inp.IndexOf("</i>", index + 4, lastIndex - index, StringComparison.Ordinal);
- if (nearestClosingIndex != lastIndex) return inp;
- inp = inp.Remove(nearestClosingIndex, 4);
- var nearestIndexFromRemoved = text.LastIndexOf("<i>", nearestClosingIndex, StringComparison.Ordinal);
- if (nearestIndexFromRemoved == index) return inp;
- return inp.Remove(nearestIndexFromRemoved, 3);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement