Skip to content

Instantly share code, notes, and snippets.

@backupbrain
Last active October 15, 2018 18:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save backupbrain/ddc26a0298d6fc0f6a47be4c32809b5a to your computer and use it in GitHub Desktop.
Save backupbrain/ddc26a0298d6fc0f6a47be4c32809b5a to your computer and use it in GitHub Desktop.
Tokenizer.prototype.trimWhitespace = function(text) {
cleanedText = text.replace(/\n+/g, "\n");
cleanedText = cleanedText.replace(/[ ]+/g, " ");
cleanedText = cleanedText.trim();
return cleanedText;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment