1

I was able to use .replace(/.{40}/g, '$&\n') to put a new line on every 40th character of a word from the input, but that cuts words in the middle. What is a wise choice in the situlation? Thanks!

shadowspawn
  • 3,039
  • 22
  • 26
Tedd
  • 11
  • 1

1 Answers1

0

I don't know the answer. That said, I'd hazard the following system might work:

  • see if the character 41 is equal to [a-zA-Z]
  • if it is indeed the middle of the word, insert a linebreak in the previous whitespace

Hope this might help!

mjwils
  • 456
  • 4
  • 12