How do I break up a string every X amount of characters? For example, I’d like to break up a very long string every 1000 characters, and the string could be completely random everytime.
var string = <my text string that is thousands of characters long>
You could use Regex:
Replace 3 with 1000 of course.
Here’s a contrived example: http://jsfiddle.net/ReRPz/1/
As a function:
That RegExp really only needs to be created once if you have a set number to split like 1000.