Created
March 28, 2017 08:27
-
-
Save Jei/e5746a1c31860be8068e76fd7786d1b4 to your computer and use it in GitHub Desktop.
Telegram message splitter regex.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The maximum length of a Telegram text message is 4096 UTF8 characters. | |
// This regex splits a string in parts of 4096 characters at most, ending with newline. | |
exports.splitMessage = function(text) { | |
return text.match(/([^\s][\w\W\n]{0,4096})(?=\n[\w\W\n]*|$)/gi); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment