console.log(rule);
// rule = max18
// rule = max120
// rule = max6
var pattMax = new RegExp('^(max).(\d{1,3})');
pattMax.test(rule); //false?
if(pattMax.test(rule)){
console.log('é max seguido de 1 á 3 digitos');
}