wxTextCtrl IP address validator

Milan Babuskov milanb at panonnet.net
Fri May 4 00:45:44 PDT 2007


kentropy wrote:
> I wonder if does exist a control or a class allowing the validation of a string containing a dot formatted IP address ?

It should be trivial to write one. IP address has a very simple format, 
it's 4 numbers 0-255 separated by 3 dots. I guess you can use wxRegEx 
class for it.

You can use regex like this:

\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b

Take a look here for details:
http://www.regular-expressions.info/examples.html

-- 
Milan Babuskov
http://www.guacosoft.com
http://www.flamerobin.org





More information about the wx-users mailing list