<?xml version="1.0" encoding="UTF-8"?><!-- generator="bbPress" -->

<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
>

<channel>
<title>Forums Topic: Using regex to validate IP address</title>
<link>http://www.tutorialhelpdesk.com/forum/</link>
<description>Tutorialhelpdesk programming forums</description>
<language>en</language>
<pubDate>Fri, 21 Nov 2008 21:26:43 +0000</pubDate>

<item>
<title>thdadmin on "Using regex to validate IP address"</title>
<link>http://www.tutorialhelpdesk.com/forum/topic/using-regex-to-validate-ip-address#post-17</link>
<pubDate>Fri, 04 Jul 2008 08:20:19 +0000</pubDate>
<dc:creator>thdadmin</dc:creator>
<guid isPermaLink="false">17@http://www.tutorialhelpdesk.com/forum/</guid>
<description>&#60;p&#62;The idea is to validate an IP address according to an IP address' format. This little bit of code uses regex to verify the range of the numbers and the format:&#60;br /&#62;
&#60;pre&#62;&#60;code&#62;&#38;lt;?php
$ip = &#38;quot;255.255.255.255&#38;quot;;
if (preg_match(
&#38;#39;/^(?:25[0-5]&#124;2[0-4]\d&#124;1\d\d&#124;[1-9]\d&#124;\d)(?:[.](?:25[0-5]&#124;2[0-4]\d&#124;1\d\d&#124;[1-9]\d&#124;\d)){3}$/&#38;#39;,$ip))
{
echo &#38;quot;IP valid.&#38;quot;;
}
else
{
echo &#38;quot;IP invalid&#38;quot;;
}&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;I used a similar method for &#60;a href=&#34;http://www.tutorialhelpdesk.com/forum/topic/very-simple-function-to-validate-email-address-in-php&#34;&#62;validating an email address&#60;/a&#62;. Also using regex.
&#60;/p&#62;</description>
</item>

</channel>
</rss>
