public static boolean isMustFieldValid(String field, String reg) {
        if (field == null || field.length() == 0) {
            return false;
        }
        return Pattern.matches(reg, field);
    }
public static boolean isMustFieldValid ( String field , String reg ) { if ( field == null || field . length ( ) == 0 ) { return false ; } return 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.