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