jquery selector and escaped brackets
<p>this is my code</p>

<pre><code>function jq(myid) { 
   return myid.replace(/(:|\.)/g,'\\$1');
 }


var old_tag=jq($.parseJSON(response).old_tag);
        $("#tagbox_"+object_type+"_"+object_id+"_tagsinput.tagsinput span.tag span:contains("+old_tag+") a").filter(function(){
...
    } 
</code></pre>

<p>Basically the first function escapes special characters to avoid an error in the following selector. My problem is that the selector doesn't work anymore, it just doesn't find what it should. Printing "old_tag", the string is correct. </p>

<p>How can i solve the problem?</p>

<p>EDIT: Html example</p>

<pre><code>&lt;form style="margin:0px"&gt;

   &lt;input id="tagbox_infodisc_discussion_198" class="tag_field" object_type="infodisc_discussion" object_id="198" owner="Infodisc" owner_id="1" cancreatetag="1" canaddtag="1" canremovetag="1" value="['abc','cde']" $type="text" style="display: none; "&gt;
&lt;div id="tagbox_infodisc_discussion_198_tagsinput" class="tagsinput"&gt;
    &lt;span class="tag"&gt;&lt;span&gt;&lt;a href="/tags/show/abc/Infodisc/1"&gt;abc&lt;/a&gt;&lt;/span&gt;&lt;a href="#" title="Removing tag" class="cross"&gt; x&lt;/a&gt;&lt;/span&gt;&lt;span class="tag"&gt;&lt;span&gt;&lt;a href="/tags/show/cde/Infodisc/1"&gt;cde&lt;/a&gt;&lt;/span&gt;&lt;a href="#" title="Removing tag" class="cross"&gt; x&lt;/a&gt;&lt;/span&gt;
    &lt;div id="tagbox_infodisc_discussion_198_addTag"&gt;
        &lt;input id="tagbox_infodisc_discussion_198_tag" value="" data-default="" style="color: rgb(102, 102, 102); " autocomplete="off"&gt;
    &lt;/div&gt;
&lt;/div&gt;
&lt;/form&gt;
</code></pre>
