Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

split string into equal chunks javascript

var str="hello how are you"
var size=3
console.log(str.match(new RegExp('.{1,' + size + '}', 'g')))
//returns ["hel","lo ","how"," ar","e y","ou"]
 
PREVIOUS NEXT
Tagged: #split #string #equal #chunks #javascript
ADD COMMENT
Topic
Name
1+1 =