Regex: Accurate IP address verification... Each numeric part of an IP address must be between ...

Posted by: RegexLib.com - Recent Patterns, on 29 Dec 2005 | View original | Bookmarked: 0 time(s)

Regex: Accurate IP address verification... Each numeric part of an IP address must be between 0 and 255. All patterns I have seen on the net cover this range but they allow leading zeros. The valid cases are: * 0 * 1, 10-19 and 100-199 aka 1[0-9]{0,2} * 2 and 20-29 aka 2[0-9]{0,1} * 200-249 aka 2[0-4][0-9] * 250-255 aka 25[0-5] * 3-9 and 30-99 aka [3-9][0-0]{0,1}

*********************************************

^((0|1[0-9]{0,2}|2[0-9]{0,1}|2[0-4][0-9]|25[0-5]|[3-9][0-9]{0,1})\.){3}(0|1[0-9]{0,2}|2[0-9]{0,1}|2[0-4][0-9]|25[0-5]|[3-9][0-9]{0,1})$

Category: Regex | Other Posts: View all posts by this blogger | Report as irrelevant | View bloggers stats | Views: 3940 | Hits: 96

Similar Posts

  • Speeding Up FireFox When Using the ASP.NET Development Server from Localhost more
  • CS Dev Guide: IP Banning more

News Categories

.NET | Agile | Ajax | Architecture | ASP.NET | BizTalk | C# | Certification | Data | DataGrid | DataSet | Debugger | DotNetNuke | Events | GridView | IIS | Indigo | JavaScript | Mobile | Mono | Patterns and Practices | Performance | Podcast | Refactor | Regex | Security | Sharepoint | Silverlight | Smart Client Applications | Software | SQL | VB.NET | Visual Studio | W3 | WCF | WinFx | WPF | WSE | XAML | XLinq | XML | XSD