Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Here's the new code:</p> <pre><code>Shared Function AdjustURL(ByVal psInput As String, ByVal psAppend As String) As String Dim sOrig As String = " " &amp; psInput 'Prepending a space (browser will ignore) in case the first character is a link. Dim sOutput As String = "" Dim iEnd As Integer = -1, iQuestion As Integer = -1 While sOrig.Length &gt; 0 sOutput &amp;= sOrig.Substring(0, 1) sOrig = sOrig.Substring(1) iEnd = -1 If sOrig.StartsWith("&lt;a href=") Then 'Is this a safe assumption, what if it's not an &lt;a&gt; or href isn't next after only one space? If sOrig.StartsWith("&lt;a href=""") Then iEnd = InStr(10, sOrig, """") 'URL ends with a Quote Else iEnd = InStr(9, sOrig, " ") 'URL ends with a Space - are there other possibilities? End If iQuestion = InStr(sOrig, "?") If iQuestion &gt; iEnd Then iQuestion = -1 sOutput &amp;= sOrig.Substring(0, iEnd - 1) &amp; IIf(iQuestion &gt; -1, "?", "&amp;") &amp; psAppend sOrig = sOrig.Substring(iEnd - 1) End If End While Return sOutput End Function </code></pre> <p>Call:</p> <pre><code>Dim sHTML As String = "&lt;table&gt; &lt;tr&gt;&lt;td&gt;&lt;a href=""url1""&gt;link1&lt;/a&gt;&lt;/td&gt; &lt;td&gt;&lt;a href=""url2""&gt;&lt;img src=""image.jpg"" /&gt;&lt;/a&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt;" Response.Write(Class1.AdjustURL(sHTML, "ID=1")) </code></pre> <p>Result:</p> <pre><code> &lt;table&gt; &lt;tr&gt;&lt;td&gt;&lt;a href="url1?ID=1"&gt;link1&lt;/a&gt;&lt;/td&gt; &lt;td&gt;&lt;a href="url2?ID=1"&gt;&lt;img src="image.jpg" /&gt;&lt;/a&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; </code></pre> <p>I'm sure there will be other replacements you will discover over time as users enter things. I'd definitely recommend replacing <code>&lt;script</code> with something like <code>&lt;span style=display:none</code> to avoid javascript injection. You'll also want to be sure to avoid SQL injection before writing this to your database.</p>
    singulars
    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. This table or related slice is empty.
    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