var foo = "foofaafoofaafoofaafoofaafoofaa"; console.log( foo.match(/.{1,3}/g) ); Run code snippetHide results