SHARE
TWEET

Untitled

a guest Apr 18th, 2019 60 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function wordwrap( str, width, brk, cut ) {
  2.      brk = brk || '\n';
  3.      width = width || 75;
  4.      cut = cut || false;
  5.  
  6.      if (!str) { return str; }
  7.  
  8.      var regex = '.{1,' +width+ '}(\\s|$)' + (cut ? '|.{' +width+ '}|.+$' : '|\\S+?(\\s|$)');
  9.  
  10.      return str.match( RegExp(regex, 'g') ).join( brk );
  11. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top