is there a way to call the codeCleaner('Word') function instead of calling the CleanCode in the Toolbar.
I tried using your regex function and it still saved a lot of word formatting junk. Surely your codeCleaner function is more robust than the regex function you provided.
Here is my version of the regex function in C#:
- public static string CleanWordHtml(string html)
- {
- String cleanstring = String.Empty;
- System.Text.RegularExpressions.Regex regex;
-
- cleanstring=html;
-
- cleanstring = System.Text.RegularExpressions.Regex.Replace(cleanstring,
- @"<\\?\??xml[^>]>", "",
- System.Text.RegularExpressions.RegexOptions.IgnoreCase);
-
- cleanstring = System.Text.RegularExpressions.Regex.Replace(cleanstring,
- @"\s*mso-[^:]+:[^;""]+;?", "",
- System.Text.RegularExpressions.RegexOptions.IgnoreCase);
-
- cleanstring = System.Text.RegularExpressions.Regex.Replace(cleanstring,
- @"<\/?\w+:[^>]*>", "",
- System.Text.RegularExpressions.RegexOptions.IgnoreCase);
-
- cleanstring = System.Text.RegularExpressions.Regex.Replace(cleanstring,
- @"<\!--.*-->", "",
- System.Text.RegularExpressions.RegexOptions.IgnoreCase);
-
- cleanstring = System.Text.RegularExpressions.Regex.Replace(cleanstring,
- @"[\”\“]", "\"\"",
- System.Text.RegularExpressions.RegexOptions.IgnoreCase);
-
- cleanstring = System.Text.RegularExpressions.Regex.Replace(cleanstring,
- @"[\‘\’]", "'",
- System.Text.RegularExpressions.RegexOptions.IgnoreCase);
-
- cleanstring = System.Text.RegularExpressions.Regex.Replace(cleanstring,
- @"<\\?\?xml[^>]*>", "",
- System.Text.RegularExpressions.RegexOptions.IgnoreCase);
-
- cleanstring = System.Text.RegularExpressions.Regex.Replace(cleanstring,
- @"<span\s*[^>]*>\s* \s*<\/span>", " ",
- System.Text.RegularExpressions.RegexOptions.IgnoreCase);
-
- cleanstring = System.Text.RegularExpressions.Regex.Replace(cleanstring,
- @"<span\s*[^>]*><\/span>", "",
- System.Text.RegularExpressions.RegexOptions.IgnoreCase);
-
- cleanstring = System.Text.RegularExpressions.Regex.Replace(cleanstring,
- @"<(\w+)[^>]*\sstyle=""[^""]*DISPLAY\s?:\s?none(.*?)<\/\1>", "",
- System.Text.RegularExpressions.RegexOptions.IgnoreCase);
-
- return cleanstring;
- }