Skip to content

Instantly share code, notes, and snippets.

@saveman71
Created October 22, 2015 08:37
Show Gist options
  • Save saveman71/219ca07c499428b40427 to your computer and use it in GitHub Desktop.
Save saveman71/219ca07c499428b40427 to your computer and use it in GitHub Desktop.
This regex will split a text in sentences respecting punctuation, and thinks like "M. Lastname" will not break the sentence
var sentences = text.match(/(M\.|Mme\.|Mlle\.|\.\w|(?:\.\.\.|…)\s+[a-z]|[^\.!\?\n…])+[\.!\?\n…]+/g);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment