public static boolean validateRequiredField(String field, String reg) {
        return !(field == null || field.isEmpty()) && Pattern.matches(reg, field);
    }
public static boolean validateRequiredField ( String field , String reg ) { return ! ( field == null || field . isEmpty ( ) ) && Pattern . matches ( reg , field ) ; }
Validate the required field String against the regex.

@param field
the field value String.
@param reg
the regex.
@return true if matched.