stright from Mastering Regular Expresstions by Oreilly page 124
Code:
^([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])\.$
this should all be on 1 line btw. the reason 0-9 wont work as mentioned above it cuz if you want a ligit ip all the time 0-9 wont work. remember 0-9 says even an ip of 999.999.999.999 is valid when we all know is not valid in any universe (yet anyways).
btw this book is a book i think everyone that is into unix, programing, scripting should read.
the hostname check is on page 167