Fixed namenode regex to be compatible with hostnames and ip addresses.

It is designed after the regex described on stack overflow for such a
problem: http://stackoverflow.com/a/106223/1477510