how to split a string every nth place in javasrcript code example Example: js split string every n characters foo.match(new RegExp('.{1,' + n + '}', 'g'));