<?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>Evolution Systems &#187; URL</title>
	<atom:link href="http://evolution-systems.co.uk/tag/url/feed/" rel="self" type="application/rss+xml" />
	<link>http://evolution-systems.co.uk</link>
	<description>Web Development, Software Development and Linux Consultancy services</description>
	<lastBuildDate>Fri, 08 Aug 2025 09:18:44 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=4.1.42</generator>
	<item>
		<title>Validating Url Strings In PHP</title>
		<link>http://evolution-systems.co.uk/2008/09/25/validating-url-strings-in-php-2/</link>
		<comments>http://evolution-systems.co.uk/2008/09/25/validating-url-strings-in-php-2/#comments</comments>
		<pubDate>Thu, 25 Sep 2008 12:25:31 +0000</pubDate>
		<dc:creator><![CDATA[Matthew Jakeman]]></dc:creator>
				<category><![CDATA[Evolution Systems]]></category>
		<category><![CDATA[Matts Blog]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[URL]]></category>
		<category><![CDATA[Validation]]></category>

		<guid isPermaLink="false">http://evolution-systems.co.uk/wordpress/?p=501</guid>
		<description><![CDATA[I was writing a form a little while ago that requests a url from a user. Obviously it would be nice to validate the string the user input in some way. I am not a fan of writing a regex for something like this when I know that there are bound to be many examples [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>I was writing a form a little while ago that requests a url from a user. Obviously it would be nice to validate the string the user input in some way. I am not a fan of writing a regex for something like this when I know that there are bound to be many examples of doing this knocking about already so to save time I once again headed over to google to look around.</p>
<p>I came across <a href="http://www.phpcentral.com/208-url-validation-php.html">this link</a> which has a nice little example of a regex to achieve a good validation.</p>
<p>Below is a copy and paste of building the regex string from that site with brief explanations of what each part achieves.</p>
<p><code>// SCHEME<br />$urlregex = "^(https?|ftp)\:\/\/";</p>
<p>// USER AND PASS (optional)<br />$urlregex .= "([a-z0-9+!*(),;?&#038;=\$_.-]+(\:[a-z0-9+!*(),;?&#038;=\$_.-]+)?@)?";<br />// HOSTNAME OR IP<br />$urlregex .= "[a-z0-9+\$_-]+(\.[a-z0-9+\$_-]+)*";<br />// PORT (optional)<br />$urlregex .= "(\:[0-9]{2,5})?"; <br />// PATH  (optional)<br />$urlregex .= "(\/([a-z0-9+\$_-]\.?)+)*\/?";// GET Query (optional)<br />$urlregex .= "(\?[a-z+&#038;\$_.-][a-z0-9;:@/&#038;%=+\$_.-]*)?";// ANCHOR (optional)<br />$urlregex .= "(#[a-z_.-][a-z0-9+\$_.-]*)?\$";</code><br />
This builds a nice regex string which can be used with the eregi() function to validate a url string like so:</p>
<p><code>if (eregi($urlregex, $url))<br />{<br />  echo "URL Valid";<br />}<br />else<br />{<br />  echo "URL Invalid";<br />}</code><br />
This regex will validate nearly all valid url&#8217;s and is handy to have knocking about.</p>
<p>Thanks to the original author, whoever that may be&#8230;..</p>
]]></content:encoded>
			<wfw:commentRss>http://evolution-systems.co.uk/2008/09/25/validating-url-strings-in-php-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
