I am a night person, the wee hours are when I get most inspired. Here's a regular expression I wrote last night, um, make that this morning. It matches an IP address, and also ensures that the values are within the allowed range (0-255). (((d{1,2})|(1d{2})|(2d)|(25)).){3}((d{1,2})|(1d{2})|(2d)|(25))