Skip to content

Instantly share code, notes, and snippets.

@jongacnik
Created June 15, 2018 23:23
Show Gist options
  • Save jongacnik/5b7347d2cddcdd6b5001072377d0273b to your computer and use it in GitHub Desktop.
Save jongacnik/5b7347d2cddcdd6b5001072377d0273b to your computer and use it in GitHub Desktop.
var striptags = require('striptags')
function smartExcerpt (string) {
var re = /(^.*?[a-zA-Z0-9\)\”\"]{2,}[.!?])[\s\”\"]+\W*[A-Z]/
var matches = striptags(string).match(re)
return matches && matches[1] ? matches[1] : string
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment