Skip to content
Advertisement

Splitting a Paragraph into 160 Character Pieces for Text Messaging

I’m having trouble with the logic of taking a paragraph of text and splitting it on words/sentences to send out in multiple text messages. Each text message can only have up to 160 characters. I want to cleanly break a paragraph up.

Here is the solution (thanks Leventix!):

JavaScript

Advertisement

Answer

You can use wordwrap, then explode by newlines:

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement