fork download
  1. class Ideone {
  2. static void main(String[] args) {
  3. String text = "Extract all words but word1 and word2."
  4. println( text.findAll(/\b(?!(?:word1|word2)\b)\w+/) )
  5. }
  6. }
  7.  
Success #stdin #stdout 1.85s 118920KB
stdin
Standard input is empty
stdout
[Extract, all, words, but, and]