It suffices if you test the regexp as the empty string does not passes the test. ,) Simpler. Furthermore, this does not exactly matches your definition as it allows XXX.YY format but is OK for me.