JSFiddle - React, Tailwind, and code Playground

JavaScript

var hidden = "aaa,bbb,ccc,ddd,eee,fff,ggg,hhh,iii";
console.log(hidden.match(/(([^,]+,){0,3}[^,]+)/g));