<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Wait...What? &#187; code</title>
	<atom:link href="http://www.johnmangino.org/tag/code/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.johnmangino.org</link>
	<description>John Mangino: for your amusement &#38; bemusement</description>
	<lastBuildDate>Mon, 02 Jan 2012 23:49:04 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Simple Regular Expressions Function for Twitter Search</title>
		<link>http://www.johnmangino.org/2010/08/simple-regular-expressions-function-for-twitter-search/</link>
		<comments>http://www.johnmangino.org/2010/08/simple-regular-expressions-function-for-twitter-search/#comments</comments>
		<pubDate>Fri, 13 Aug 2010 14:04:06 +0000</pubDate>
		<dc:creator>john</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.johnmangino.org/?p=15</guid>
		<description><![CDATA[Doing some work that involves Twitter&#8217;s search api. When a call is made JSON returns text of each message, which is to be expected, but many posts have &#8220;@soandso&#8221; or &#8220;http://bit.ly/dDnSkQ&#8221; or something, and that kind of info can&#8217;t just &#8230; <a href="http://www.johnmangino.org/2010/08/simple-regular-expressions-function-for-twitter-search/">Continue reading <span class="meta-nav">&#8594;</span></a>
]]></description>
			<content:encoded><![CDATA[<a href='http://twitter.com/share?url=http%3A%2F%2Fwww.johnmangino.org%2F%3Fp%3D15&count=none&related=johnmangino&text=Simple%20Regular%20Expressions%20Function%20for%20Twitter%20Search' class='twitter-share-button' data-text='Simple Regular Expressions Function for Twitter Search' data-url='http://www.johnmangino.org/?p=15' data-counturl='http://www.johnmangino.org/2010/08/simple-regular-expressions-function-for-twitter-search/' data-count='none' data-via='johnmangino' data-related='johnmangino'></a><div class="posterous_autopost">

Doing some work that involves Twitter's <a href="http://apiwiki.twitter.com/Twitter-Search-API-Method%3A-search">search api</a>. When a call is made JSON returns text of each message, which is to be expected, but many posts have "@soandso" or "http://bit.ly/dDnSkQ" or something, and that kind of info can't just be left to sit there now can it?
No it can not.<span id="more-15"></span>
However, Using PHP, by applying some very simple regular expression functions in a method, voila! Links GAlore.
Using preg_replace you can quickly and easily replace each text version of '@johnmangino' with <a href="http://twitter.com/johnmangino">@johnmangino</a>. The only "trick" here is to use the parenthesis to give you a reference that will allow you to make the user link without the '@'.  Here is a quick function used within the loop to href the links. Import the function and run the text through it like so:
<pre>$text = $r-&gt;text;  $text = makeRich($text);</pre>
So here is the function.

<script src="http://gist.github.com/485487.js?file=makerich.php"></script>

Very very simple, but I'm finding it helpful in a few places. Right, I'm sure this can be greatly improved upon, but I hope it helps someone.

Ok. Bye.
<p style="font-size: 10px;"><a href="http://posterous.com">Posted via web</a> from <a href="http://johnmangino.posterous.com/simple-regular-expressions-function-for-twitt">John Mangino's posterous</a></p>

</div>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'Simple Regular Expressions Function for Twitter Search on John Mangino\&#039;s Wait...What?',url: 'http://www.johnmangino.org/2010/08/simple-regular-expressions-function-for-twitter-search/',contentID: 'post-15',suggestTags: 'api,code,development,php',providerName: 'John Mangino\&#039;s Wait...What?',styling: 'text' });return false" class="evernoteSiteMemoryLink"><img src="http://static.evernote.com/article-clipper.png" class="evernoteSiteMemoryButton" />
				</a>				<div class="evernoteSiteMemoryClear">&nbsp;</div>
</div><a href='http://twitter.com/share?url=http%3A%2F%2Fwww.johnmangino.org%2F%3Fp%3D15&count=none&related=johnmangino&text=Simple%20Regular%20Expressions%20Function%20for%20Twitter%20Search' class='twitter-share-button' data-text='Simple Regular Expressions Function for Twitter Search' data-url='http://www.johnmangino.org/?p=15' data-counturl='http://www.johnmangino.org/2010/08/simple-regular-expressions-function-for-twitter-search/' data-count='none' data-via='johnmangino' data-related='johnmangino'></a><script type='text/javascript'>
<!--
tweetmeme_source = 'tweetmeme';
tweetmeme_url = 'http://www.johnmangino.org/2010/08/simple-regular-expressions-function-for-twitter-search/';
//-->
</script><script type="text/javascript" src="http://tweetmeme.com/i/scripts/button.js"></script>]]></content:encoded>
			<wfw:commentRss>http://www.johnmangino.org/2010/08/simple-regular-expressions-function-for-twitter-search/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

