Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- text = ''
- +'nAs I looked to the east right into the sun,'
- +'nI saw a tower on a toft worthily built;'
- +'nA deep dale beneath a dungeon therein,'
- +'nWith deep ditches and dark and dreadful of sight'
- +'nA fair field full of folk found I in between,'
- +'nOf all manner of men the rich and the poor,'
- +'nWorking and wandering as the world asketh.'
- skipWords = ['the', 'and']
- curr = []
- text.toLowerCase().replace(/bw{3,}b/g, function(word) {
- if (skipWords.indexOf(word) >= 0)
- return;
- var len = curr.length
- if (!len || curr[len - 1].charAt(0) == word.charAt(0))
- curr.push(word)
- else {
- if (len > 2)
- console.log(curr)
- curr = [word]
- }
- })
- ["deep", "ditches", "dark", "dreadful"]
- ["fair", "field", "full", "folk", "found"]
- ["working", "wandering", "world"]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement