Module: Word::Extract
- Defined in:
- lib/word/extract.rb
Instance Method Summary collapse
-
#extract_words(wildcard = Word::WILDCARD) ⇒ Object
“a b ‘c d’” => [“a”, “b”, “"c d"”].
Instance Method Details
#extract_words(wildcard = Word::WILDCARD) ⇒ Object
“a b ‘c d’” => [“a”, “b”, “"c d"”]
5 6 7 8 |
# File 'lib/word/extract.rb', line 5 def extract_words(wildcard = Word::WILDCARD) word = /".*?"|'.*?'|#{wildcard}?\w+#{wildcard}?/ # "word1 word2" | 'word1 word2' | word scan(word).flatten.map{|x| x.gsub(/"|'/, '"')}.uniq end |