snipt

Ctrl+h for KB shortcuts

C#

Remove <p></p> tags from a string...

literal.Text = Regex.Replace(q.Custom2, "<.*?>", string.Empty);  // Added as a temp fix to remove <p>...</p> tags from Custom2 field in database.  CKEditor is adding those tags when not wanted..
https://snipt.net/embed/7fab991d8a7efd347845fb6b64800560/
https://snipt.net/raw/7fab991d8a7efd347845fb6b64800560/
7fab991d8a7efd347845fb6b64800560
csharp
C#
1
2016-08-17T00:38:25
True
False
True
May 02, 2013 at 03:20 PM
/api/public/snipt/60512/
remove-pp-tags-from-a-string
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a><span class="n">literal</span><span class="p">.</span><span class="n">Text</span> <span class="p">=</span> <span class="n">Regex</span><span class="p">.</span><span class="n">Replace</span><span class="p">(</span><span class="n">q</span><span class="p">.</span><span class="n">Custom2</span><span class="p">,</span> <span class="s">&quot;&lt;.*?&gt;&quot;</span><span class="p">,</span> <span class="kt">string</span><span class="p">.</span><span class="n">Empty</span><span class="p">);</span> <span class="c1">// Added as a temp fix to remove &lt;p&gt;...&lt;/p&gt; tags from Custom2 field in database. CKEditor is adding those tags when not wanted..</span> </span></pre></div> </td></tr></table>
regex, tags

PHP

php script tags

1
2
3
<script language="php">
	echo('script tags');
</script>
https://snipt.net/embed/4f4e72d5b38da54542a2491a2731c0bb/
https://snipt.net/raw/4f4e72d5b38da54542a2491a2731c0bb/
4f4e72d5b38da54542a2491a2731c0bb
php
PHP
4
2016-09-21T21:50:53
True
False
False
Sep 06, 2012 at 07:52 AM
/api/public/snipt/46775/
php-script-tags
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a><span class="x">&lt;script language=&quot;php&quot;&gt;</span> </span><span id="L-2"><a name="L-2"></a><span class="x"> echo(&#39;script tags&#39;);</span> </span><span id="L-3"><a name="L-3"></a><span class="x">&lt;/script&gt;</span> </span></pre></div> </td></tr></table>
php, script, scripttags, tags, valid

Python

remove html tags from a string

1
2
3
4
5
6
7
8
import re
import urllib

data = urllib.urlopen( "http://www.evilsocket.net/" ).read() 

data = re.sub( r'<[^>]*>', ' ', data ).strip()

print data
https://snipt.net/embed/99456d0075c23dd950a8ea2385ab1235/
https://snipt.net/raw/99456d0075c23dd950a8ea2385ab1235/
99456d0075c23dd950a8ea2385ab1235
python
Python
8
2016-10-01T06:05:53
True
False
False
/api/public/snipt/25767/
remove-html-tags-from-a-string
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a> <a href="#L-5">5</a> <a href="#L-6">6</a> <a href="#L-7">7</a> <a href="#L-8">8</a></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a><span class="kn">import</span> <span class="nn">re</span> </span><span id="L-2"><a name="L-2"></a><span class="kn">import</span> <span class="nn">urllib</span> </span><span id="L-3"><a name="L-3"></a> </span><span id="L-4"><a name="L-4"></a><span class="n">data</span> <span class="o">=</span> <span class="n">urllib</span><span class="o">.</span><span class="n">urlopen</span><span class="p">(</span> <span class="s">&quot;http://www.evilsocket.net/&quot;</span> <span class="p">)</span><span class="o">.</span><span class="n">read</span><span class="p">()</span> </span><span id="L-5"><a name="L-5"></a> </span><span id="L-6"><a name="L-6"></a><span class="n">data</span> <span class="o">=</span> <span class="n">re</span><span class="o">.</span><span class="n">sub</span><span class="p">(</span> <span class="s">r&#39;&lt;[^&gt;]*&gt;&#39;</span><span class="p">,</span> <span class="s">&#39; &#39;</span><span class="p">,</span> <span class="n">data</span> <span class="p">)</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> </span><span id="L-7"><a name="L-7"></a> </span><span id="L-8"><a name="L-8"></a><span class="k">print</span> <span class="n">data</span> </span></pre></div> </td></tr></table>
html, python, sanitize, strip, strip_tags, tags

AppleScript

Create nested tag in DTP

1
2
3
tell application "DEVONthink Pro"
	create record with {name:"Test", type:group} in tag group named "KM Sales Tax" of database named "Legal & Risk Management"
end tell
https://snipt.net/embed/f56417d887ca391ad7c71ce13e4ef0b8/
https://snipt.net/raw/f56417d887ca391ad7c71ce13e4ef0b8/
f56417d887ca391ad7c71ce13e4ef0b8
applescript
AppleScript
3
2016-09-30T02:12:11
True
False
False
/api/public/snipt/22483/
create-nested-tag-in-dtp
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a><span class="k">tell</span> <span class="nb">application</span> <span class="s2">&quot;DEVONthink Pro&quot;</span> </span><span id="L-2"><a name="L-2"></a> <span class="nv">create</span> <span class="nv">record</span> <span class="nv">with</span> <span class="p">{</span><span class="na">name</span><span class="p">:</span><span class="s2">&quot;Test&quot;</span><span class="p">,</span> <span class="nv">type</span><span class="p">:</span><span class="nv">group</span><span class="p">}</span> <span class="k">in</span> <span class="na">tag</span> <span class="nv">group</span> <span class="nv">named</span> <span class="s2">&quot;KM Sales Tax&quot;</span> <span class="k">of</span> <span class="nv">database</span> <span class="nv">named</span> <span class="s2">&quot;Legal &amp; Risk Management&quot;</span> </span><span id="L-3"><a name="L-3"></a><span class="k">end</span> <span class="k">tell</span> </span></pre></div> </td></tr></table>
devonthink, tags

AppleScript

Add tag to current database in DevonThink

1
2
3
tell application "DEVONthink Pro"
	create record with {name:"Test", type:group} in tags group of current database
end tell
https://snipt.net/embed/df8841a335e438536a8ac2eb2d07d2db/
https://snipt.net/raw/df8841a335e438536a8ac2eb2d07d2db/
df8841a335e438536a8ac2eb2d07d2db
applescript
AppleScript
3
2016-09-30T22:14:24
True
False
False
/api/public/snipt/22482/
add-tag-to-current-database-in-devonthink
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a><span class="k">tell</span> <span class="nb">application</span> <span class="s2">&quot;DEVONthink Pro&quot;</span> </span><span id="L-2"><a name="L-2"></a> <span class="nv">create</span> <span class="nv">record</span> <span class="nv">with</span> <span class="p">{</span><span class="na">name</span><span class="p">:</span><span class="s2">&quot;Test&quot;</span><span class="p">,</span> <span class="nv">type</span><span class="p">:</span><span class="nv">group</span><span class="p">}</span> <span class="k">in</span> <span class="nv">tags</span> <span class="nv">group</span> <span class="k">of</span> <span class="nv">current</span> <span class="nv">database</span> </span><span id="L-3"><a name="L-3"></a><span class="k">end</span> <span class="k">tell</span> </span></pre></div> </td></tr></table>
devonthink, tags

PHP

Include post count usage in get_tags for Wordpress

1
2
3
4
5
<?php $tags = get_tags( array('number' => '10', 'orderby' => 'count', 'order' => 'DESC') ); foreach ( (array) $tags as $tag ) { ?>

<?php echo '<a href="' . get_tag_link ($tag->term_id) . '" rel="tag">' . $tag->name . '' . $tag->count . '</a>';	?>

<?php } ?>
https://snipt.net/embed/29437f12cdfac1efb3f2b67a4db45800/
https://snipt.net/raw/29437f12cdfac1efb3f2b67a4db45800/
29437f12cdfac1efb3f2b67a4db45800
php
PHP
5
2016-09-30T16:20:54
True
False
False
/api/public/snipt/16441/
include-post-count-usage-in-get_tag
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a> <a href="#L-5">5</a></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a><span class="cp">&lt;?php</span> <span class="nv">$tags</span> <span class="o">=</span> <span class="nx">get_tags</span><span class="p">(</span> <span class="k">array</span><span class="p">(</span><span class="s1">&#39;number&#39;</span> <span class="o">=&gt;</span> <span class="s1">&#39;10&#39;</span><span class="p">,</span> <span class="s1">&#39;orderby&#39;</span> <span class="o">=&gt;</span> <span class="s1">&#39;count&#39;</span><span class="p">,</span> <span class="s1">&#39;order&#39;</span> <span class="o">=&gt;</span> <span class="s1">&#39;DESC&#39;</span><span class="p">)</span> <span class="p">);</span> <span class="k">foreach</span> <span class="p">(</span> <span class="p">(</span><span class="k">array</span><span class="p">)</span> <span class="nv">$tags</span> <span class="k">as</span> <span class="nv">$tag</span> <span class="p">)</span> <span class="p">{</span> <span class="cp">?&gt;</span><span class="x"></span> </span><span id="L-2"><a name="L-2"></a> </span><span id="L-3"><a name="L-3"></a><span class="cp">&lt;?php</span> <span class="k">echo</span> <span class="s1">&#39;&lt;a href=&quot;&#39;</span> <span class="o">.</span> <span class="nx">get_tag_link</span> <span class="p">(</span><span class="nv">$tag</span><span class="o">-&gt;</span><span class="na">term_id</span><span class="p">)</span> <span class="o">.</span> <span class="s1">&#39;&quot; rel=&quot;tag&quot;&gt;&#39;</span> <span class="o">.</span> <span class="nv">$tag</span><span class="o">-&gt;</span><span class="na">name</span> <span class="o">.</span> <span class="s1">&#39;&#39;</span> <span class="o">.</span> <span class="nv">$tag</span><span class="o">-&gt;</span><span class="na">count</span> <span class="o">.</span> <span class="s1">&#39;&lt;/a&gt;&#39;</span><span class="p">;</span> <span class="cp">?&gt;</span><span class="x"></span> </span><span id="L-4"><a name="L-4"></a> </span><span id="L-5"><a name="L-5"></a><span class="cp">&lt;?php</span> <span class="p">}</span> <span class="cp">?&gt;</span><span class="x"></span> </span></pre></div> </td></tr></table>
get_tags, tags, wordpress
Copyrighted, illegal, or inappropriate content? Email support@snipt.net.