Refactored version validation to use a regular expression.