Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I'd use parser to parse HTML like <a href="http://htmlagilitypack.codeplex.com/" rel="nofollow">HtmlAgilityPack</a>, and use regular expressions to find the <code>color</code> value in attributes.</p> <p>First, find all the nodes that contain <code>style</code> attribute with <code>color</code> defined in it by using xpath:</p> <pre><code>var doc = new HtmlDocument(); doc.LoadHtml(html); var nodes = doc.DocumentNode .SelectNodes("//*[contains(@style, 'color')]") .ToArray(); </code></pre> <p>Then the simplest regex to match a color value: <code>(?&lt;=color:\s*)#?\w+</code>.</p> <pre><code>var colorRegex = new Regex(@"(?&lt;=color:\s*)#?\w+", RegexOptions.IgnoreCase); </code></pre> <p>Then iterate through these nodes and if there is a regex match, replace the inner html of the node with html encoded tags (you'll understand why a little bit later):</p> <pre><code>foreach (var node in nodes) { var style = node.Attributes["style"].Value; if (colorRegex.IsMatch(style)) { var color = colorRegex.Match(style).Value; node.InnerHtml = HttpUtility.HtmlEncode("&lt;" + color + "&gt;") + node.InnerHtml + HttpUtility.HtmlEncode("&lt;/" + color + "&gt;"); } } </code></pre> <p>And finally get the inner text of the document and perform html decoding on it (this is because inner text strips all the tags):</p> <pre><code>var txt = HttpUtility.HtmlDecode(doc.DocumentNode.InnerText); </code></pre> <p>This should return something like this:</p> <pre><code>This is a sample html text. &lt;#ff9999&gt;this is only a sample&lt;/#ff9999&gt; .... and some other tags... </code></pre> <p>Of course you could improve it for your needs.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload