Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The most robust solution would be to use the <a href="http://html-agility-pack.net/?z=codeplex" rel="nofollow noreferrer">HTMLAgilityPack</a> as others have suggested. However a reasonable solution using regular expressions is possible using the <a href="http://msdn.microsoft.com/en-us/library/ht1sxswy.aspx" rel="nofollow noreferrer">Replace</a> overload that takes a <a href="http://msdn.microsoft.com/en-us/library/system.text.regularexpressions.matchevaluator.aspx" rel="nofollow noreferrer">MatchEvaluator</a> delegate, as follows:</p> <pre><code>var baseUri = new Uri("http://test.com"); var pattern = @"(?&lt;name&gt;src|href)=""(?&lt;value&gt;/[^""]*)"""; var matchEvaluator = new MatchEvaluator( match =&gt; { var value = match.Groups["value"].Value; Uri uri; if (Uri.TryCreate(baseUri, value, out uri)) { var name = match.Groups["name"].Value; return string.Format("{0}=\"{1}\"", name, uri.AbsoluteUri); } return null; }); var adjustedHtml = Regex.Replace(originalHtml, pattern, matchEvaluator); </code></pre> <p>The above sample searches for attributes named src and href that contain double quoted values starting with a forward slash. For each match, the static <a href="http://msdn.microsoft.com/en-us/library/ms131573.aspx" rel="nofollow noreferrer">Uri.TryCreate</a> method is used to determine if the value is a valid relative uri.</p> <p>Note that this solution doesn't handle single quoted attribute values and certainly doesn't work on poorly formed HTML with unquoted values.</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.
    3. 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