snipt

Ctrl+h for KB shortcuts

Text only

example of "tweet this post"

http://twitter.com/home/?status=MS+PICKS+%7C+DOIN+IT+IN+THE+PARK+2009+http://e2ih4.th8.us
https://snipt.net/embed/714f357e844162b669ebf172e7adab9a/
/raw/714f357e844162b669ebf172e7adab9a/
714f357e844162b669ebf172e7adab9a
text
Text only
1
2019-07-18T09:53:45
True
False
False
/api/public/snipt/8281/
example-of-tweet-this-post
<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></span><span id="L-1"><a name="L-1"></a>http://twitter.com/home/?status=MS+PICKS+%7C+DOIN+IT+IN+THE+PARK+2009+http://e2ih4.th8.us </span></pre></div> </td></tr></table>
twitter

JavaScript

Find Twitter Links

1
2
3
4
5
var urlregexp = /((ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?)/gi;
var tweet = "TWITTER STRING HERE";
	tweet = tweet.replace(urlregexp, "<a href='$1' target='_blank'>$1</a>");
	tweet = tweet.replace(/(^|\s)@(\w+)/g, "$1<a href='http://www.twitter.com/$2'>@$2</a>");
	tweet = tweet.replace(/(^|\s)#(\w+)/g, "$1<a href='http://search.twitter.com/search?q=%23$2'>#$2</a>");
https://snipt.net/embed/bf2cf502483810fdaae08148b452f6ff/
/raw/bf2cf502483810fdaae08148b452f6ff/
bf2cf502483810fdaae08148b452f6ff
js
JavaScript
5
2019-07-19T12:22:54
True
False
False
/api/public/snipt/7195/
find-twitter-links-1
<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></span><span id="L-1"><a name="L-1"></a><span class="kd">var</span> <span class="nx">urlregexp</span> <span class="o">=</span> <span class="sr">/((ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&amp;%@!\-\/]))?)/gi</span><span class="p">;</span> </span><span id="L-2"><a name="L-2"></a><span class="kd">var</span> <span class="nx">tweet</span> <span class="o">=</span> <span class="s2">&quot;TWITTER STRING HERE&quot;</span><span class="p">;</span> </span><span id="L-3"><a name="L-3"></a> <span class="nx">tweet</span> <span class="o">=</span> <span class="nx">tweet</span><span class="p">.</span><span class="nx">replace</span><span class="p">(</span><span class="nx">urlregexp</span><span class="p">,</span> <span class="s2">&quot;&lt;a href=&#39;$1&#39; target=&#39;_blank&#39;&gt;$1&lt;/a&gt;&quot;</span><span class="p">);</span> </span><span id="L-4"><a name="L-4"></a> <span class="nx">tweet</span> <span class="o">=</span> <span class="nx">tweet</span><span class="p">.</span><span class="nx">replace</span><span class="p">(</span><span class="sr">/(^|\s)@(\w+)/g</span><span class="p">,</span> <span class="s2">&quot;$1&lt;a href=&#39;http://www.twitter.com/$2&#39;&gt;@$2&lt;/a&gt;&quot;</span><span class="p">);</span> </span><span id="L-5"><a name="L-5"></a> <span class="nx">tweet</span> <span class="o">=</span> <span class="nx">tweet</span><span class="p">.</span><span class="nx">replace</span><span class="p">(</span><span class="sr">/(^|\s)#(\w+)/g</span><span class="p">,</span> <span class="s2">&quot;$1&lt;a href=&#39;http://search.twitter.com/search?q=%23$2&#39;&gt;#$2&lt;/a&gt;&quot;</span><span class="p">);</span> </span></pre></div> </td></tr></table>
twitter

PHP

Find Twitter links

$ret = preg_replace("#(^|[\n ])([\w]+?://[\w]+[^ \"\n\r\t<]*)#ise", "'\\1<a href=\"\\2\" >\\2</a>'", $ret);
$ret = preg_replace("#(^|[\n ])((www|ftp)\.[^ \"\t\n\r<]*)#ise", "'\\1<a href=\"http://\\2\" >\\2</a>'", $ret);
https://snipt.net/embed/aa6128b97ad610a097b88d40e0ffeeb1/
/raw/aa6128b97ad610a097b88d40e0ffeeb1/
aa6128b97ad610a097b88d40e0ffeeb1
php
PHP
2
2019-07-23T02:25:55
True
False
False
/api/public/snipt/7193/
find-twitter-links
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="x">$ret = preg_replace(&quot;#(^|[\n ])([\w]+?://[\w]+[^ \&quot;\n\r\t&lt;]*)#ise&quot;, &quot;&#39;\\1&lt;a href=\&quot;\\2\&quot; &gt;\\2&lt;/a&gt;&#39;&quot;, $ret);</span> </span><span id="L-2"><a name="L-2"></a><span class="x">$ret = preg_replace(&quot;#(^|[\n ])((www|ftp)\.[^ \&quot;\t\n\r&lt;]*)#ise&quot;, &quot;&#39;\\1&lt;a href=\&quot;http://\\2\&quot; &gt;\\2&lt;/a&gt;&#39;&quot;, $ret);</span> </span></pre></div> </td></tr></table>
twitter