---
title: "Discussion on \"How to split string to strings of equal length in JavaScript?\" | Hashnode"
description: "Discussion on \"How to split string to strings of equal length in JavaScript?\". Solution\n'abcdabcdabcdabcdabcd'.match(/.{1,4}/g)\n// ['abcd', 'abcd', 'abcd', 'abcd', 'abcd']\n\nHere's original StackOverflow answer. \nContext\nIn today's Advent of Code challenge, I had to simulate drawing pixels on 40x6 CRT screen. First I computed li..."
url: "https://hashnode.com/posts/how-to-split-string-to-strings-of-equal-length-in-javascript/63945d1b21a257bd0d9f5a9f"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [How to split string to strings of equal length in JavaScript?](https://blog.macieksitkowski.com/how-to-split-string-to-strings-of-equal-length-in-javascript?utm_source=hashnode&utm_medium=feed)

Solution 'abcdabcdabcdabcdabcd'.match(/.{1,4}/g) // \['abcd', 'abcd', 'abcd', 'abcd', 'abcd'\] Here's original StackOverflow answer. Context In today's Advent of Code challenge, I had to simulate drawing pixels on 40x6 CRT screen. First I computed li...

Dec 10, 2022 · 1 min read · blog.macieksitkowski.com  
Read the article

-   [#adventofcode2022](https://hashnode.com/tag/adventofcode2022)
-   [#javascript](https://hashnode.com/tag/javascript)

## Written by

[Maciek Sitkowski](https://hashnode.com/@sitek94)

@sitek94 · Poland

  
[View profile](https://hashnode.com/@sitek94)

mostly frontend

## Responses

Markdown supported · ⌘↵ to post

No responses yet.
