<?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>DevtheWeb.NET &#187; pattern</title>
	<atom:link href="http://www.devtheweb.net/blog/tag/pattern/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.devtheweb.net/blog</link>
	<description></description>
	<lastBuildDate>Tue, 06 Dec 2011 19:25:18 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>My URL Pattern</title>
		<link>http://www.devtheweb.net/blog/2010/02/12/my-url-pattern/</link>
		<comments>http://www.devtheweb.net/blog/2010/02/12/my-url-pattern/#comments</comments>
		<pubDate>Fri, 12 Feb 2010 08:51:39 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[pattern]]></category>

		<guid isPermaLink="false">http://www.devtheweb.net/blog/?p=933</guid>
		<description><![CDATA[I needed a url pattern that recognizes the following urls: http://site.com www.site.com https://site.com https://www.site.com Even more, I wanted after url detection, it to be replaced with: http://site.com -&#62; http://site.com www.site.com -&#62; http://www.site.com https://site.com -&#62; https://site.com https://www.site.com -&#62; https://www.site.com I use Regex&#8217;s Replace method. It detects all urls and replaces them with the correct format. Here [...]]]></description>
			<content:encoded><![CDATA[<p>I needed a url pattern that recognizes the following urls:</p>
<p>http://site.com</p>
<p>www.site.com</p>
<p>https://site.com</p>
<p>https://www.site.com</p>
<p>Even more, I wanted after url detection, it to be replaced with:</p>
<p>http://site.com -&gt; http://site.com</p>
<p>www.site.com -&gt; http://www.site.com</p>
<p>https://site.com -&gt; https://site.com</p>
<p>https://www.site.com -&gt; https://www.site.com</p>
<p>I use Regex&#8217;s Replace method. It detects all urls and replaces them with the correct format. Here is the full example:</p>
<p>string originalText;</p>
<p>&#8230;</p>
<p>string convertedText = Regex.Replace(originalText,<br />
@&#8221;((http(?&lt;http1&gt;(s?))://(?&lt;www1&gt;(www.)))|(http(?&lt;http2&gt;(s?))://)|((?&lt;www2&gt;(www.))))(?&lt;url&gt;([wd:#@%/;$()~_?+-=\.&amp;]*))&#8221;,<br />
@&#8221;http${http1}${http2}://${www1}${www2}${url}&#8221;);</p>
<p>&#8230;</p>
<p>P.S. I hope that the example above could be useful to someone else, too. If you find some bug or suggestion, I&#8217;ll be very thankful to hear how it can be fixed <img src='http://www.devtheweb.net/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.devtheweb.net/blog/2010/02/12/my-url-pattern/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

