Validating IPv4 addresses with regexp
Best for Now (43 chars) ^((25[0-5]|(2[0-4]|1\d|[1-9]|)\d)\.?\b){4}$ This version shortens things by another 6 characters while not making use of the negative lookahead, which is not supported in some regex flavors. Newest, Shortest, Least Readable Version (49 chars) ^((25[0-5]|(2[0-4]|1\d|[1-9]|)\d)(\.(?!$)|$)){4}$ The [0-9] blocks can be substituted by \d in 2 places – makes it a bit less … Read more