Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- linesCount () {
- if (this.selectedNote) {
- // Count the number of new line characters
- return this.selectedNote.content.split(/\r\n|\r|\n/).length
- }
- },
- wordsCount () {
- if (this.selectedNote) {
- var s = this.selectedNote.content
- // Turn new line cahracters into white-spaces
- s = s.replace(/\n/g, ' ')
- // Exclude start and end white-spaces
- s = s.replace(/(^\s*)|(\s*$)/gi, '')
- // Turn 2 or more duplicate white-spaces into 1
- s = s.replace(/\s\s+/gi, ' ')
- // Return the number of spaces
- return s.split(' ').length
- }
- },
- charactersCount () {
- if (this.selectedNote) {
- return this.selectedNote.content.split('').length
- }
- },
Add Comment
Please, Sign In to add comment