JavaScript (Node.js), 46 bytes
s=>/^.{9},.{13},.{9}$/.test(s.map(c=>c%7||.1))
Take input as array of digits. Output truthy vs. falsy.
s.map(c=>c%7||.1)
mapping each digits to a number. Digits 0 or 7 which has 2 syllables are mapped into0.1
while others are mapped into an 1 digit number.RegExp.prototype.test
converts its parameter intostring
. The mapping result is an array. When try to convert array into a string, each elements are converted into string and connected by a comma (,
). So, basically, each digits in the string is 1 syllable. And commas between theme mean you can break line here, while dots mean you cannot break line here.- Finally,
/^.{9},.{13},.{9}$/
test if the string has a 5-7-5 syllables pattern.