fork download
  1. keywords = ['one', 'one two', 'three']
  2. keywords = keywords.dup.sort.reverse
  3. re = /\b(?i:#{ Regexp.union(keywords).source })\b/
  4. text = 'Some word one and one two other word'
  5. puts text.downcase.scan(re)
Success #stdin #stdout 0.02s 9848KB
stdin
Standard input is empty
stdout
one
one two