const re = { digi: /nyo[!-\/,:-@,\[-`,{-~]{0,3}$/ig, petit: /nyu[!-\/,:-@,\[-`,{-~]{0,3}$/ig, rabi: /[a-z,0-9]/ig, gema: /gema[!-\/,:-@,\[-`,{-~]{0,3}$/ig, piyo: /pyo[!-\/,:-@,\[-`,{-~]{0,3}$/ig } console.log( require('fs') .readFileSync('/dev/stdin', 'utf8') .split('\n') .slice(0, -1) .map(v => v.split(' ')) .map(v => v.slice(1, v.length) .join `` .match(re[v[0]]) && v.length > 1 && re[v[0]] ? 'CORRECT (maybe)' : 'WRONG!') .join('\n') );