Guest User

Untitled

a guest
Jun 18th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. linesCount () {
  2. if (this.selectedNote) {
  3. // Count the number of new line characters
  4. return this.selectedNote.content.split(/\r\n|\r|\n/).length
  5. }
  6. },
  7.  
  8. wordsCount () {
  9. if (this.selectedNote) {
  10. var s = this.selectedNote.content
  11. // Turn new line cahracters into white-spaces
  12. s = s.replace(/\n/g, ' ')
  13. // Exclude start and end white-spaces
  14. s = s.replace(/(^\s*)|(\s*$)/gi, '')
  15. // Turn 2 or more duplicate white-spaces into 1
  16. s = s.replace(/\s\s+/gi, ' ')
  17. // Return the number of spaces
  18. return s.split(' ').length
  19. }
  20. },
  21.  
  22. charactersCount () {
  23. if (this.selectedNote) {
  24. return this.selectedNote.content.split('').length
  25. }
  26. },
Add Comment
Please, Sign In to add comment