// replace <br /> tags with new line characters string replaceContent = Regex.Replace(contentText, @"", "\n"); // add full stop to inner text of an element, if it needs one, to separate from next word when tags removed replaceContent = Regex.Replace(replaceContent, @"\w(?=)", @"$0\."); // remove all tags and leading and trailing space replaceContent = Regex.Replace(replaceContent, "<.*?>", string.Empty).Trim(); CommonMethods.WordMatchCollection = CommonMethods.WordRegularExpression.Matches(replaceContent); // match words which are not in tags string pattern = @"(?<!<[^>]*?)\b(\w+|\w+['-]\w+)\b(?![^<]*?>)"; string replacement = "<span>$0</span>"; // surround words in text with <span> tags contentText = Regex.Replace(contentText, pattern, replacement); return contentText;</span>
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)