<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Automatically linking Twitter @usernames in PHP</title>
	<atom:link href="http://neverusethisfont.com/blog/2008/10/automatically-linking-twitter-usernames/feed/" rel="self" type="application/rss+xml" />
	<link>http://neverusethisfont.com/blog/2008/10/automatically-linking-twitter-usernames/</link>
	<description>Ramblings of a Designer/Programmer</description>
	<lastBuildDate>Thu, 20 May 2010 01:16:01 -0700</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Gavin</title>
		<link>http://neverusethisfont.com/blog/2008/10/automatically-linking-twitter-usernames/comment-page-1/#comment-7878</link>
		<dc:creator>Gavin</dc:creator>
		<pubDate>Fri, 26 Mar 2010 15:14:31 +0000</pubDate>
		<guid isPermaLink="false">http://neverusethisfont.com/blog/2008/10/automatically-linking-twitter-usernames/#comment-7878</guid>
		<description>helped me solve a problem I was having with my own twitter parser, cheers :)</description>
		<content:encoded><![CDATA[<p>helped me solve a problem I was having with my own twitter parser, cheers <img src='http://neverusethisfont.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: thanking you!</title>
		<link>http://neverusethisfont.com/blog/2008/10/automatically-linking-twitter-usernames/comment-page-1/#comment-6016</link>
		<dc:creator>thanking you!</dc:creator>
		<pubDate>Sat, 14 Nov 2009 06:02:12 +0000</pubDate>
		<guid isPermaLink="false">http://neverusethisfont.com/blog/2008/10/automatically-linking-twitter-usernames/#comment-6016</guid>
		<description>thanks. just what i needed. works perfectly =)

thank you.</description>
		<content:encoded><![CDATA[<p>thanks. just what i needed. works perfectly =)</p>
<p>thank you.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Medical Revision</title>
		<link>http://neverusethisfont.com/blog/2008/10/automatically-linking-twitter-usernames/comment-page-1/#comment-5216</link>
		<dc:creator>Medical Revision</dc:creator>
		<pubDate>Thu, 03 Sep 2009 18:46:47 +0000</pubDate>
		<guid isPermaLink="false">http://neverusethisfont.com/blog/2008/10/automatically-linking-twitter-usernames/#comment-5216</guid>
		<description>Hey man - thanks a lot for this. You helped me understand regex a lot better. Hopefully will have it working properly on allaboutchris.co.uk soon!</description>
		<content:encoded><![CDATA[<p>Hey man &#8211; thanks a lot for this. You helped me understand regex a lot better. Hopefully will have it working properly on allaboutchris.co.uk soon!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: aaron</title>
		<link>http://neverusethisfont.com/blog/2008/10/automatically-linking-twitter-usernames/comment-page-1/#comment-4792</link>
		<dc:creator>aaron</dc:creator>
		<pubDate>Fri, 31 Jul 2009 17:32:57 +0000</pubDate>
		<guid isPermaLink="false">http://neverusethisfont.com/blog/2008/10/automatically-linking-twitter-usernames/#comment-4792</guid>
		<description>@larry: the /i flag makes the regex case-insensitive, so it&#039;s not necessary to include A-Z. /[a-zA-z]/ and /[a-z]/i are equivalent expressions.</description>
		<content:encoded><![CDATA[<p>@larry: the /i flag makes the regex case-insensitive, so it&#8217;s not necessary to include A-Z. /[a-zA-z]/ and /[a-z]/i are equivalent expressions.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ferodynamics</title>
		<link>http://neverusethisfont.com/blog/2008/10/automatically-linking-twitter-usernames/comment-page-1/#comment-4782</link>
		<dc:creator>Ferodynamics</dc:creator>
		<pubDate>Fri, 31 Jul 2009 02:08:40 +0000</pubDate>
		<guid isPermaLink="false">http://neverusethisfont.com/blog/2008/10/automatically-linking-twitter-usernames/#comment-4782</guid>
		<description>I doubt Twitter scans their database to see if a username actually exists (before linking to it) because that would slow things down.  I saw a tweet today on Twitter&#039;s website: &quot;sold @2.45&quot; meaning &quot;sold at $2.45&quot; and Twitter assumed this was user &quot;2&quot; cut off at the period.  Twitter.com/2 actually exists, which is all the more tragic.  So if I incorrectly match an email address, I hereby apologize in advance ;-)</description>
		<content:encoded><![CDATA[<p>I doubt Twitter scans their database to see if a username actually exists (before linking to it) because that would slow things down.  I saw a tweet today on Twitter&#8217;s website: &#8220;sold @2.45&#8243; meaning &#8220;sold at $2.45&#8243; and Twitter assumed this was user &#8220;2&#8243; cut off at the period.  Twitter.com/2 actually exists, which is all the more tragic.  So if I incorrectly match an email address, I hereby apologize in advance <img src='http://neverusethisfont.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: larry</title>
		<link>http://neverusethisfont.com/blog/2008/10/automatically-linking-twitter-usernames/comment-page-1/#comment-4763</link>
		<dc:creator>larry</dc:creator>
		<pubDate>Wed, 29 Jul 2009 14:13:39 +0000</pubDate>
		<guid isPermaLink="false">http://neverusethisfont.com/blog/2008/10/automatically-linking-twitter-usernames/#comment-4763</guid>
		<description>Don&#039;t forget to include A-Z in the for capitalized letters</description>
		<content:encoded><![CDATA[<p>Don&#8217;t forget to include A-Z in the for capitalized letters</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: aaron</title>
		<link>http://neverusethisfont.com/blog/2008/10/automatically-linking-twitter-usernames/comment-page-1/#comment-4506</link>
		<dc:creator>aaron</dc:creator>
		<pubDate>Tue, 30 Jun 2009 17:45:00 +0000</pubDate>
		<guid isPermaLink="false">http://neverusethisfont.com/blog/2008/10/automatically-linking-twitter-usernames/#comment-4506</guid>
		<description>@cometbus

That actually just occurred to me the other day when I was writing some code to parse some text that has an equal chance of containing Twitter usernames as it does email addresses. Typically tweets don&#039;t contain email addresses so it isn&#039;t usually a problem.

Here is my updated regex.

preg_replace(&#039;/(^&#124;[^a-z0-9_])@([a-z0-9_]+)/i&#039;, &#039;$1&lt;a href=&quot;http://twitter.com/$2&quot; &gt;@$2&lt;/a&gt;&#039;, $tweet);

This requires either a non-alphanumeric character preceding the @ sign, or matches the username at the beginning of the line.</description>
		<content:encoded><![CDATA[<p>@cometbus</p>
<p>That actually just occurred to me the other day when I was writing some code to parse some text that has an equal chance of containing Twitter usernames as it does email addresses. Typically tweets don&#8217;t contain email addresses so it isn&#8217;t usually a problem.</p>
<p>Here is my updated regex.</p>
<p>preg_replace(&#8217;/(^|[^a-z0-9_])@([a-z0-9_]+)/i&#8217;, &#8216;$1&lt;a href=&#8221;http://twitter.com/$2&#8243; &gt;@$2&lt;/a&gt;&#8217;, $tweet);</p>
<p>This requires either a non-alphanumeric character preceding the @ sign, or matches the username at the beginning of the line.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Cometbus</title>
		<link>http://neverusethisfont.com/blog/2008/10/automatically-linking-twitter-usernames/comment-page-1/#comment-4504</link>
		<dc:creator>Cometbus</dc:creator>
		<pubDate>Tue, 30 Jun 2009 17:16:14 +0000</pubDate>
		<guid isPermaLink="false">http://neverusethisfont.com/blog/2008/10/automatically-linking-twitter-usernames/#comment-4504</guid>
		<description>Even with the fixes in the comments, consider this:

@cometbus have you seen @ahem&#039;s last tweet? You can email me at foo@example.com.  #contactme@email.

You will get :
@cometbus
@ahem
@example
@email</description>
		<content:encoded><![CDATA[<p>Even with the fixes in the comments, consider this:</p>
<p>@cometbus have you seen @ahem&#8217;s last tweet? You can email me at <a href="mailto:foo@example.com">foo@example.com</a>.  #contactme@email.</p>
<p>You will get :<br />
@cometbus<br />
@ahem<br />
@example<br />
@email</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: aaron</title>
		<link>http://neverusethisfont.com/blog/2008/10/automatically-linking-twitter-usernames/comment-page-1/#comment-4169</link>
		<dc:creator>aaron</dc:creator>
		<pubDate>Wed, 25 Mar 2009 21:05:19 +0000</pubDate>
		<guid isPermaLink="false">http://neverusethisfont.com/blog/2008/10/automatically-linking-twitter-usernames/#comment-4169</guid>
		<description>@Remco thanks for catching that. I&#039;ve updated the post.</description>
		<content:encoded><![CDATA[<p>@Remco thanks for catching that. I&#8217;ve updated the post.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Remco Tolsma</title>
		<link>http://neverusethisfont.com/blog/2008/10/automatically-linking-twitter-usernames/comment-page-1/#comment-4062</link>
		<dc:creator>Remco Tolsma</dc:creator>
		<pubDate>Mon, 09 Mar 2009 14:41:36 +0000</pubDate>
		<guid isPermaLink="false">http://neverusethisfont.com/blog/2008/10/automatically-linking-twitter-usernames/#comment-4062</guid>
		<description>@aaron The second example is not working correctly. You should first replace the links within the tweet and then the @username.

$search = array(&#039;&#124;(http://[^ ]+)&#124;&#039;, &#039;&#124;@([0-9a-z_]+)&#124;&#039;);
$replace = array(&#039;&lt;a href=&quot;$1&quot; rel=&quot;nofollow&quot;&gt;$1&lt;/a&gt;&#039;, &#039;@&lt;a href=&quot;http://twitter.com/$1&quot; rel=&quot;nofollow&quot;&gt;$1&lt;/a&gt;&#039;);</description>
		<content:encoded><![CDATA[<p>@aaron The second example is not working correctly. You should first replace the links within the tweet and then the @username.</p>
<p>$search = array(&#8217;|(http://[^ ]+)|&#8217;, &#8216;|@([0-9a-z_]+)|&#8217;);<br />
$replace = array(&#8217;<a href="$1" rel="nofollow">$1</a>&#8216;, &#8216;@<a href="http://twitter.com/$1" rel="nofollow">$1</a>&#8216;);</p>
]]></content:encoded>
	</item>
</channel>
</rss>
