A pattern to match IP-Adresses proposed by O’Reilly:
^([01]?\d\d?|2[0-4]\d|25[0-5])\.([01]?\d\d?|2[0-4]\d|25[0-5])\.([01]?\d\d?|2[0-4]\d|25[0-5])\.([01]?\d\d?|2[0-4]\d|25[0-5])$
That’s a quite long string, here a shortened Version (Javascript compatible):
^((25[0-5]|2[0-4]\d|[01]?\d{1,2})(\.(?!$)|$)){4}
even shorter:
^((25[0-5]|(2[0-4]|[01]?\d?)\d)(\.(?!$)|$)){4}
And a bit longer however stricter:
^((25[0-5]|(2[0-4]|[01]?\d?)\d)(\.(?=\d)|$)){4}
MarcO (so called MO) wrote a small html to test the patterns:
ronny.html
update:
MarcO found another testcase, so here a new Version:
^((25[0-5]|(2[0-4]|[01]?\d?)\d)(\.(?!$)|$)){4}$
plus a new html:
ronny2