Find words which contains more than 3 e vowels: Difference between revisions

→‎{{header|jq}}: regex-free solution
(→‎{{header|jq}}: regex-free solution)
Line 698:
{{works with|jq}}
'''Works with gojq, the Go implementation of jq'''
 
===Using regular expressions===
<lang jq>inputs
| select(test("[aiou]")|not)
| select(test("e.*e.*e.*e"))</lang>
===Regex-free solution===
<lang jq>def count(s): reduce s as $x (null; .+1);
 
("aiou" | explode) as $disallow
| inputs
| . as $word
| explode
| select( all(.[]; . != $disallow[]) and
count(.[] | select(. == 101)) > 3) # "e" is 101
| $word
</lang>
{{out}}
Invocation example: jq -nrR program.jq unixdict.txt
2,471

edits