// @author NoName <tz4678@gmail.com> // wordWrap(s, width=78) function wordWrap(s, width) { width = width || 78 var r = '(?:(.{1,' + width + '})[ \\t\\r]+|(.{' + width + '}))(?!$)'; r = new RegExp(r, 'g'); return s.replace(r, '$1$2\n'); }