<?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>Lunesta For Sale</title>
	<atom:link href="http://www.reynoldsftw.com/tag/regular-expressions/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.reynoldsftw.com</link>
	<description>Being Generalist.</description>
	<lastBuildDate>Fri, 03 Sep 2010 19:00:35 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Lunesta For Sale</title>
		<link>http://www.reynoldsftw.com/2009/03/reformat-urls-with-javascript-and-regular-expressions/</link>
		<comments>http://www.reynoldsftw.com/2009/03/reformat-urls-with-javascript-and-regular-expressions/#comments</comments>
		<pubDate>Fri, 06 Mar 2009 12:52:47 +0000</pubDate>
		<dc:creator>Steve Reynolds</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[RegExp]]></category>
		<category><![CDATA[Regular Expressions]]></category>

		<guid isPermaLink="false">http://www.reynoldsftw.com/?p=839</guid>
		<description><![CDATA[As part of the Chatterbloc project we had a requirement to do a couple of things: Lunesta For Sale, Reformat www. links with http://www. Replace http:// strings with an HTML A link equivalent Surprisingly I found it pretty hard to find a hard and fast solution for this that had already been done, buy Lunesta [...]]]></description>
			<content:encoded><![CDATA[<p> As part of the <a href="http://www.chatterbloc.com" target="_blank">Chatterbloc project</a> we had a requirement to do a couple of things:<br />
<ol><br />
	<li> <b>Lunesta For Sale</b>, Reformat www. links with http://www.</li><br />
	<li>Replace http:// strings with an HTML A link equivalent</li><br />
</ol><br />
Surprisingly I found it pretty hard to find a hard and fast solution for this that had already been done, <b>buy Lunesta from canada</b>, <b>Buy Lunesta from mexico</b>, so I either wasn't looking properly, or it doesn't exist, <b>buy Lunesta without a prescription</b>.  <b>Order Lunesta no prescription</b>, Anyway, I created two functions for this piece of work, <b>where can i order Lunesta without prescription</b>, <b>Lunesta samples</b>, I'll show you those, and also how to use them, <b>order Lunesta</b>.  <b>Order Lunesta online c.o.d</b>, <h3>Convert www to http://www</h3><br />
So my first problem was to change <em>www.google.com</em> to <em>http://www.google.com</em>. I came up with the solution below as a function:</p>
<p>[sourcecode language="jscript"]function replacewww(text) {</p>
<p>var start = (text.indexOf(&quot;www&quot;))-7;<br />
var match = text.substr(start, <b>buy cheap Lunesta no rx</b>, <b>Buy Lunesta online cod</b>, 7);<br />
if(match != &quot;http://&quot; &amp;&amp; match != &quot;ttps://&quot;)<br />
{<br />
text = text.replace(&quot;www&quot;, &quot;http://www&quot;);<br />
}</p>
<p>return text;<br />
}[/sourcecode]</p>
<p>This is quite a basic string manipulation - literally looking for an index of www in my text string, <b>rx free Lunesta</b>, <b>Lunesta pharmacy</b>, and taking out the match -7 characters. That will tell me whether there is <strong>http://</strong> or <strong>https://</strong> in front of the <strong>www</strong>, <b>Lunesta For Sale</b>. If there isn't, <b>buy generic Lunesta</b>, <b>Buy Lunesta without prescription</b>, the function replaces the www with http://. What this function doesn't do is know whether it should be http:// or https://, <b>order Lunesta from mexican pharmacy</b>, <b>Online buying Lunesta</b>, it assumes http:// is the more likely candidate.</p>
<p>[ad#in-ad-unit-hor]<br />
<h3>Convert links to HTML A HREFs</h3><br />
The next part is where I needed a regular expression to hunt down the start and end of a URL, <b>order Lunesta no prescription</b>, <b>Where can i buy cheapest Lunesta online</b>, and replace it with the HTML equivalent, ie</p>
<p>[sourcecode language="html"]&lt;a href=&quot;http://www.google.com&quot;&gt;http://www.google.com&lt;/a&gt;[/sourcecode]</p>
<p>The reason why I used a regular expression was that it was increasingly difficult to find the end of a url using string manipulation, <b>buy Lunesta without a prescription</b>, <b>Lunesta for sale</b>, it was never guaranteed (you could argue the same with regular expressions), however I found that I had much more success with using a regular expression match to make it happen:</p>
<p>[sourcecode language="jscript"]function replaceURLWithHTMLLinks(text) {<br />
var exp = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&amp;@#\/%?=~_|!:, <b>Lunesta samples</b>, <b>Where can i buy Lunesta online</b>, .;]*[-A-Z0-9+&amp;@#\/%=~_|])/ig;<br />
return text.replace(exp,&quot;&lt;a href='$1' target='_blank'&gt;$1&lt;/a&gt;&quot;);<br />
}[/sourcecode]</p>
<p>This function simply does a string replace based on a regular expression match, <b>buy Lunesta from mexico</b>.  <b>Order Lunesta from mexican pharmacy</b>, The $1 part is obviously the matched element, ie the URL which is placed where necessary within the HTML tags, <b>buy generic Lunesta</b>.<br />
<h3>Making it happen</h3> <b>Lunesta For Sale</b>, So, the reason why I separated these two functions was because I would actually not always require both of them at the same time, so it made sense in my implementation to keep them as two.  <b>Purchase Lunesta online</b>, You could however, push them all into one function for ease of use, <b>Lunesta price</b>.  <b>Online buy Lunesta without a prescription</b>, Anyway, I'm sure its obvious on how to make this work, <b>australia, uk, us, usa, canada, mexico, india, craiglist, ebay</b>, <b>Buy Lunesta without prescription</b>, however I'll show you so it's quite clear.</p>
<p>[sourcecode language="jscript"]var newHTML;<br />
var stringInput = &quot;Check out this link www.google.com&quot;;</p>
<p>newHTML = replacewww(stringInput);<br />
newHTML = replaceURLWithHTMLLinks(newHTML);</p>
<p>document.write(newHTML);<br />
}[/sourcecode]<br />
<h3>Conclusion</h3><br />
I hope you found this basic tutorial helpful... As I like to mention - I'm here to help the common man/woman, more than the über nerd, so I hope this article was a nice fit for what you needed. Look forward to hearing from you as always...<br />
<h3>Tools to help you learn...</h3><br />
<table border="0" cellspacing="0" cellpadding="0" width="100%"><br />
<thead></thead><br />
<tbody><br />
<tr><br />
<td width="33%" align="center" valign="top"></p>
<p>[caption id="attachment_613" align="aligncenter" width="101" caption="Learning jQuery 1.3"]<a href="http://www.amazon.com/gp/product/1847196705?ie=UTF8&amp;tag=stereyblo-20&amp;linkCode=as2&amp;camp=1789&amp;creative=9325&amp;creativeASIN=1847196705"><img class="size-full wp-image-613" title="jquery13" src="http://www.reynoldsftw.com/wp-content/uploads/2009/02/jquery13.jpg" alt="Learning jQuery 1.3" width="101" height="132" /></a>[/caption]</p>
<p><img style="border:none !important; margin:0px !important;" src="http://www.assoc-amazon.com/e/ir?t=stereyblo-20&amp;l=as2&amp;o=1&amp;a=1847196705" border="0" alt="" width="1" height="1" /></td><br />
<td width="33%" align="center" valign="top"></p>
<p>[caption id="attachment_770" align="aligncenter" width="101" caption="Amazon Kindle 2"]<a href="http://www.amazon.com/gp/product/B00154JDAI?ie=UTF8&amp;tag=stereyblo-20&amp;linkCode=as2&amp;camp=1789&amp;creative=9325&amp;creativeASIN=B00154JDAI"><img class="size-full wp-image-770" title="kindle" src="http://www.reynoldsftw.com/wp-content/uploads/2009/03/kindle.jpg" alt="Amazon Kindle 2" width="101" height="132" /></a>[/caption]</p>
<p><img style="border:none !important; margin:0px !important;" src="http://www.assoc-amazon.com/e/ir?t=stereyblo-20&amp;l=as2&amp;o=1&amp;a=B00154JDAI" border="0" alt="" width="1" height="1" /></td><br />
<td width="33%" align="center" valign="top"></p>
<p>[caption id="attachment_612" align="aligncenter" width="101" caption="jQuery UI 1.6"]<a href="http://www.amazon.com/gp/product/1847195121?ie=UTF8&amp;tag=stereyblo-20&amp;linkCode=as2&amp;camp=1789&amp;creative=9325&amp;creativeASIN=1847195121"><img class="size-full wp-image-612" title="jquery-ui" src="http://www.reynoldsftw.com/wp-content/uploads/2009/02/jquery-ui.jpg" alt="jQuery UI 1.6" width="101" height="132" /></a>[/caption]</p>
<p><img style="border:none !important; margin:0px !important;" src="http://www.assoc-amazon.com/e/ir?t=stereyblo-20&amp;l=as2&amp;o=1&amp;a=1847195121" border="0" alt="" width="1" height="1" /></td><br />
</tr><br />
</tbody></table>.</p>
<p></p>
<p><b>Similar posts:</b> <a href='http://www.reynoldsftw.com/?p=1762'>Buy Modalert Without Prescription</a>. <a href='http://www.reynoldsftw.com/?p=1864'>Motofen For Sale</a>. <a href='http://www.reynoldsftw.com/?p=1812'>Order Fludiazepam no prescription</a>. <a href='http://www.reynoldsftw.com/?p=1374'>Where can i buy cheapest Asendin online</a>.<br />
<b>Trackbacks from:</b> <a href='http://www.imaginativestudios.com/blog/?p=948'>Lunesta For Sale</a>. <a href='http://www.crossfitminneapolis.com/?p=625'>Lunesta For Sale</a>. <a href='http://blog.latinovations.com/?p=4661'>Lunesta For Sale</a>. <a href='http://www.technow.com.hk/?p=23586'>Lunesta For Sale</a>. <a href='http://basketball.hawkmania.com/?p=565'>Lunesta For Sale</a>. <a href='http://www.selectproperty.com/?p=9256'>Buy no prescription Lunesta online</a>. <a href='http://havefaithinworthlessknowledge.com/?p=2484'>Rx free Lunesta</a>. <a href='http://www.mcgeesmusings.net/?p=1217'>Lunesta price</a>. <a href='http://www.onlinemarketingseo.com/?p=2819'>Order Lunesta online c.o.d</a>. <a href='http://www.tuverde.com/?p=16812'>Order Lunesta</a>. <a href='http://americaninlima.com/?p=1280'>Australia, uk, us, usa, canada, mexico, india, craiglist, ebay</a>. <a href='http://www.biz2credit.com/blog/?p=1486'>Where can i buy Lunesta online</a>. <a href='http://www.brentter.com/?p=596'>Rx free Lunesta</a>. <a href='http://www.curvecommunications.com/blog/?p=1976'>Where can i order Lunesta without prescription</a>. <a href='http://www.qualitypeoples.com/?p=10165'>Buy no prescription Lunesta online</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.reynoldsftw.com/2009/03/reformat-urls-with-javascript-and-regular-expressions/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
