Note that there are some explanatory texts on larger screens.

plurals
  1. POLinks Regex Replace HTML with new
    primarykey
    data
    text
    <p>I'm trying to run a regex to to do this:</p> <p>Replace all instances of an apk file in a document:</p> <pre><code>&lt;a href="http://download.mydomain.com/files/androidfile.apk"&gt; </code></pre> <p>With:</p> <pre><code>&lt;a target="_blank" href="http://mydomain.com?f=http://download.mydomain.com/files/androidfile.apk"&gt; </code></pre> <p>With this JQUERY code:</p> <pre><code>$('body').contents().filter(function() { return this.nodeType === 3; }).each(function() { $(this).replaceWith($(this).text().replace(/&lt;a href~/^.*\.(apk)$/i, 'http://mydomain.com?f="&gt;$1&lt;/a&gt;')); }); </code></pre> <p>So essentially, remove the code before <code>download.mydomain.com/files/androidfile.apk</code>, that is <code>&lt;a href="http://</code> and replace with <code>&lt;a target="_blank" href="http://mydomain.com?f=http://</code>. There might be several of this in a page so I need a solution that might match and replace all.</p> <p>The Regex and replacing doesn't seem to work, what might be a solution to this.</p> <p>So in summary, I want to be able to do this in JQuery:</p> <pre><code>&lt;html&gt; &lt;a href="http://download.domain.com/files/androidfile1.apk"&gt;&lt;img src="theme/download.gif" border=0 alt="download" height="120px" width="130px"&gt;&lt;/a&gt;&lt;br/&gt; &lt;a href="http://download.domain.com/files/androidfile2.apk"&gt;&lt;img src="theme/download.gif" border=0 alt="download" height="120px" width="130px"&gt;&lt;/a&gt;&lt;br/&gt; &lt;a href="http://download.domain.com/files/androidfile3.apk"&gt;&lt;img src="theme/download.gif" border=0 alt="download" height="120px" width="130px"&gt;&lt;/a&gt;&lt;br/&gt; &lt;a href="http://download.domain.com/files/androidfile4.apk"&gt;&lt;img src="theme/download.gif" border=0 alt="download" height="120px" width="130px"&gt;&lt;/a&gt;&lt;br/&gt; &lt;a href="http://download.domain.com/files/androidfile5.apk"&gt;&lt;img src="theme/download.gif" border=0 alt="download" height="120px" width="130px"&gt;&lt;/a&gt;&lt;br/&gt; &lt;/html&gt; </code></pre> <p>To this:</p> <pre><code>&lt;html&gt; &lt;a href="http://mydomain2.com?f=http://download.domain.com/files/androidfile1.apk"&gt;&lt;img src="theme/download.gif" border=0 alt="download" height="120px" width="130px"&gt;&lt;/a&gt;&lt;br/&gt; &lt;a href="http://mydomain2.com?f=http://download.domain.com/files/androidfile2.apk"&gt;&lt;img src="theme/download.gif" border=0 alt="download" height="120px" width="130px"&gt;&lt;/a&gt;&lt;br/&gt; &lt;a href="http://mydomain2.com?f=http://download.domain.com/files/androidfile3.apk"&gt;&lt;img src="theme/download.gif" border=0 alt="download" height="120px" width="130px"&gt;&lt;/a&gt;&lt;br/&gt; &lt;a href="http://mydomain2.com?f=http://download.domain.com/files/androidfile4.apk"&gt;&lt;img src="theme/download.gif" border=0 alt="download" height="120px" width="130px"&gt;&lt;/a&gt;&lt;br/&gt; &lt;a href="http://mydomain2.com?f=http://download.domain.com/files/androidfile5.apk"&gt;&lt;img src="theme/download.gif" border=0 alt="download" height="120px" width="130px"&gt;&lt;/a&gt;&lt;br/&gt; &lt;/html&gt; </code></pre>
    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. 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