You need to use the switch block, something like below to achieve this,
let regexp, message;
switch (yourFormatType) {
case 'format1':
regexp = Format1_REGEXP;
message = 'The input is not a valid Format1';
break;
case 'format2':
default:
regexp = Format2_REGEXP;
message = 'The input is not a...